adobelivecyclelivecycle-designer

Adobe Livecycle ES4: Conditionally bind xml child nodes to a table


I currently have a set of xml child nodes that are bound to a table using the data binding of CustomerInvoice.PriceAndTax.PriceComponents[*].

The PriceComponent element structure is:

 <PriceComponents>
        <Description languageCode="EN">Value Added Tax (%)</Description>
        <Rate>
          <DecimalValue>13.5</DecimalValue>
          <MeasureUnitCode>P1</MeasureUnitCode>
        </Rate>
        <RateBaseQuantityTypeName languageCode="EN"> </RateBaseQuantityTypeName>
        <RateBaseMeasureUnitName languageCode="EN"> </RateBaseMeasureUnitName>
        <CalculationBasis>
          <BaseCode>1</BaseCode>
          <Amount currencyCode="EUR">1500.00</Amount>
        </CalculationBasis>
        <CalculationBasisBaseName languageCode="EN">Percentage (of one hundred)</CalculationBasisBaseName>
        <CalculationBasisQuantityMeasureUnitName languageCode="EN"> </CalculationBasisQuantityMeasureUnitName>
        <CalculationBasisQuantityTypeName languageCode="EN"> </CalculationBasisQuantityTypeName>
        <CalculatedAmount currencyCode="EUR">202.50</CalculatedAmount>
      </PriceComponents>

Currently this is outputting all the PriceComponent nodes to the table in the form, I want it to only output the nodes that have a description of Value Added Tax (%).

Is there a way to do this in the Object Palette - Binding - Data Binding property?


Solution

  • I ended up solving this using a script.

    I added a sub form to the table, nested in the repeating row. In here I added the fields from the CustomerInvoice.PriceAndTax.PriceComponents child nodes that I wanted to display and the Description field to check the value of.

    The structure of the table

    -- tblVATAnalysis    
          -- HeaderRow
             --- header fields ---    
          -- MainRow
          -- Row1
             -- colRate
             -- colSupplies
             -- colVATAmount
          -- HiddenRow
             -- lblDescription
             -- decRate
             -- decSupplies
             -- decVATAmount
    

    Then I added the following script:

    FormInvoiceRequest.bdyMain.frmSummaryData.tblVATAnalysis.MainRow.HiddenRow
        ::initialize - (FormCalc, client)
    
                var content = "";
    
                if(this.decRate.rawValue <> null & this.decRate.rawValue <> "")
                then    
                    if(this.lblDescription.rawValue == "VAT (%)")
                    then
                        content = this.decRate.rawValue;
                    endif
    
                    if(this.parent.parent.frmTaxAmount.decTaxAmount == 0)
                    then
                        if(this.lblDescription.rawValue == "Total Item Net Value")
                        then
                            content = this.decRate.rawValue;
                        endif
                    endif
                endif
    
                if(content <> "")
                then
                    FormInvoiceRequest.bdyMain.frmSummaryData.tblVATAnalysis.MainRow.Row1
                    .colRate.rawValue = content;
                else
                    FormInvoiceRequest.bdyMain.frmSummaryData.tblVATAnalysis.MainRow.Row1
                    .presence = "hidden";
                endif
    

    This populates a variable called content if the row has a description of VAT (%), then if content doesn't have a value the row is hidden.