Expand my Community achievements bar.

Assigning data from Repeatable Segments to target

Avatar

Level 2

Hello team,

I am naive to Adobe live cycle designer, apologies if it is a a very basic question.

A segment in my invoice XML keeps repeating, but the identifier and the amount keep changing for every occurence of taxsummary. Example as below the target fields in my adobe form have to populated based on the <Ident> field, if it GST put <TaxableAmount> to TAX_GST, if it PST put <TaxableAmount> to TAX_PST.

<TaxSummary>
     <Tax>
         <TaxTypeCodedOther>
             <Identifier>
                 <Agency>
                     <AgencyCoded>Other</AgencyCoded>
                         <AgencyCodedOther>GST</AgencyCodedOther>
                         </Agency>
                             <Ident>GST</Ident>
                         </Identifier>
                     <TaxableAmount>52500.00</TaxableAmount>
         </TaxTypeCodedOther>
     </Tax>
</TaxSummary>
<TaxSummary>
     <Tax>
         <TaxTypeCodedOther>
             <Identifier>
                 <Agency>
                     <AgencyCoded>Other</AgencyCoded>
                         <AgencyCodedOther>GST</AgencyCodedOther>
                         </Agency>
                             <Ident>PST</Ident>
                         </Identifier>
                     <TaxableAmount>9500.00</TaxableAmount>
         </TaxTypeCodedOther>
     </Tax>
</TaxSummary>
<TaxSummary>
     <Tax>
         <TaxTypeCodedOther>
             <Identifier>
                 <Agency>
                     <AgencyCoded>Other</AgencyCoded>
                         <AgencyCodedOther>GST</AgencyCodedOther>
                         </Agency>
                             <Ident>HST</Ident>
                         </Identifier>
                     <TaxableAmount>1500.00</TaxableAmount>
         </TaxTypeCodedOther>
     </Tax>
</TaxSummary>

I  managed to write something like this on the calculate event:

if (xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary[0].Tax.TaxTypeCodedOther.Identifier.Ident == "HST")

then

this.rawValue = xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary[0].Tax.TaxAmount

elseif (xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary[1].Tax.TaxTypeCodedOther.Identifier.Ident == "HST")

then

this.rawValue = xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary[1].Tax.TaxAmount

elseif (xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary[2].Tax.TaxTypeCodedOther.Identifier.Ident == "HST")

then

this.rawValue = xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary[2].Tax.TaxAmount

elseif (xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary[3].Tax.TaxTypeCodedOther.Identifier.Ident == "HST")

then

this.rawValue = xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary[3].Tax.TaxAmount

endif

trying to get this working with a foreach statement but does not seem to work, can anyone please suggest the solution using the foreach statement or something is JavaScript is also helpful..

Thanks,

harry..

5 Replies

Avatar

Former Community Member

Hello Harry,

  Try the below syntax and replace your code.

this is in formcalc.

    var List = ref(xfa.record.Invoice.InvoiceSummary.ListOfTaxSummary.TaxSummary)
    for i=0 upto List.nodes.length - 1 step 1 do
         $.rawValue = List.nodes.item(i).Tax.TaxAmount.value    

    endfor

Or the syntax for foreach you can use is:

var total = 0.0

foreach expense in ( travel_exp[*], living_exp[*],parking_exp[*] ) do

total = total + expense

endfor

Hope this helps.

Regards,

Chaitanya

Avatar

Level 2

Hi Chaitu,

Thanks for your response, still getting the error as enclosed. Also can you please elaborate the foreach statement you provided earlier.

Harry

Avatar

Former Community Member

May be the syntax is wrong. Instead of xfa.data.record...

can you try on this similar lines:

xfa.datasets.data.purchaseOrder.general.poNum.value

my xml data structure is something similar to this:

<?xml version="1.0" encoding="UTF-8" ?>
- <purchaseOrder>
- <general>
<poNum>8745236985</poNum>
<poDate>2004-02-08</poDate>
</general>
- <order>
<companyName>Any Company Name</companyName>
<address>555, Any Blvd.</address>
<city>Any City</city>
<stateProv>ST</stateProv>
<zipCode>12345</zipCode>
<country>Any Country</country>
<phone>(123) 456-7890</phone>
<fax>(123) 456-7899</fax>
<contactName>Contact Name</contactName>
</order>
Try to parse your data structure in the similar way. Hope this helps.
Chaitanya

Avatar

Level 2

Hi Chaitanya,

I wrote something like this and it worked.

var List = ref(xfa.datasets.data.Invoice.InvoiceSummary.ListOfTaxSummary)

var value

  for i=0 upto List.nodes.length - 1 step 1 do

    if (List.nodes.item(i).Tax.TaxTypeCodedOther.Identifier.Ident.value == "QST")

    then

    value = List.nodes.item(i).Tax.TaxAmount.value

   endif               

   endfor

    $.rawValue =  value