Dear all,
I’m having problems referencing extracted fields in detail tables from javascript.
My XML looks like:
- ExportInvoice
- Invoice
- HeaderData
- InvoiceAddress
- DeliveryAddress
- SalesTable
- InvoiceLine
- SalesTable
- Invoice
In this particular case I have 24 InvoiceLine nodes. Although they’re all marked as InvoiceLine in the XML, they actually are not: some are main items, some are supplementary items, some are backorder, some are charges, some are discounts and some I don’t even need. Due to how I need each type to be printed on the invoice I must seperate them.
So in the datamapper I loop over the InvoiceLines, extract just enough fields to be able to distinguish the types and then use a multiple conditions step to handle each type.
In the extraction “InvoiceLines” I create the detail table “record.InvoiceLines” with 4 extracted fields and one “calculated” field based on those four. In this calculation I reference the 4 extracted fields this way:
var index = steps.currentLoopCounter - 1;
var SLisSupplementaryItem = record.tables.InvoiceLines[index].fields.SLisSupplementaryItem;
In the extraction “Mains” I create the detail table “record.MainItems” with numerous extracted fields.
So far, so good. This works very nice. I get a mapped data structure like this:
- record [2]
- BackorderLines [2]
- InvoiceLines [24]
- MainItems [6]
- Charges [0]
- Discounts [1]
- Supplements [3]
- SalesTableTexts [3]
My problem starts when I want to add a “calculated” field to the MainItems table. I have no problem referencing an extracted field from record, but when I try to refernce one from the MainItems table it fails.
var test = record.fields.Oneshot;
works perfectly, however (similar to what I’ve done for the record.InvoiceLines table) this doesn’t:
var index = steps.currentLoopCounter - 1;
var test = record.tables.MainItems[index].fields.SLSItemGroupId;
This fails with error message:
It seems 0 is the only accepted value for “index” but in that case the SLSItemGroupId of the first main item is always returned, while I should have the one from the current main item.
Can anyone explain why the identical concept works for record.InvoiceLines, but not for record.MainItems and how I should correctly reference the latter’s extracted fields?
Thanks!