How to access the current object in a Repeat Step

Hi,

I have repeating items in a XML file:

...
<POS>
 <COUNT>10<COUNT/>
 <PRICE>3.99<PRICE/>
<POS>
<POS>
 <COUNT>20<COUNT/>
 <PRICE>5.00<PRICE/>
<POS>
...

To extract the fields, I use a “Repeat Step” that iterates over all “POS”-elements.

That works fine, but now I want to add an Extraction Step that multiplies two of the extracted fields (“COUNT” and “PRICE”) and adds a new field “SUM” that is set to “39.90” and “100.00”, as if the XML did contain:

<POS>
 <COUNT>10<COUNT/>
 <PRICE>3.99<PRICE/>
 
````<SUM>39.90<SUM/>`
`<POS>`

<POS>
<COUNT>20<COUNT/>
<PRICE>5.00<PRICE/>

````<SUM>100.00<SUM/> <POS>`

How can I access the fields “COUNT” and “PRICE” of the current element in the Repeat Step (which uses a “For Each”) and put the result into “SUM”?

Horrido,

Thomas

Hello Thomas,

What you want to do is going to be done in the Designer. In the DataMapper, you are extracting the data, not creating new one. A simple script will multiply those two fields and replace a text value like @SUM@.

Hope this helps!

Regards,

JF

Hi JF,

thanks for this super-fast answer!

However, I’d like to compute that new value in the DataMapper and set it to the newly added field. All I need to do (as far as I understand) is to let the expression return the computed value. This should be simple, but one needs to access other values of the current element in the loop.

Horrido,

Thomas

Hi JF,

I tried your proposal - it works, but as those resulting valuesare required for SUBTOTAL- and SUBTOTAL-calculations, I’d prefer to calculate the value once, store it with the corresponding detail-record and simply use it later.

Horrido,

Thomas

Can you please detail more what you want to achieve with your subtotals? Where and why are you going to use it later?

It is going to calculate for each record.

Regards,

JF

All of the POS-Tags will be read as “detail”-records to be used for a dynamic table; the SUM will be printed in every single line; the SUBTOTAL / TOTAL must sum up all SUM-fields.
I just want to keep the JavaScript in the dynamic table as simple as it can be.
If I can prepare the SUM-field for each POS-Tag in the DataMapper, I can use the built-in dynamic tables out of the box.

I already managed to calculate and set the value of other fields, but in this case I need to know how to refer to the fields PRICE and COUNT of the current “ROW” in the DataMapper.

Horrido,

Thomas