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..