Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Table fields populated via selection in 1

Avatar

Former Community Member

Hello,

I have a form that has a table. In the table I want to have 2 Drop-down lists in the same row.  Changing either one of these will populate the other AND some text fields in the table's same row.  So in the below table, selecting either of the dropdowns in the first 2 columns should populate the first 4 columns with the data associated with that item in the XML. How do all these fields get connected? I have seen them connected when filling the form from the XML data, via the Purchase Order sample, but not interactively, which is my goal.  This needs to ultimately work with Reader.

ItemNumberEstimatedQtyUnitContractUnitPriceHeader 5Header 6Header 7
Drop-down1Drop-down2AutoFilled Text1AutoFilled Decimal1User Entry FieldUser Entry FieldCalculated Field







The drop downs and other information is coming from a XLM using a XSD.  Here is the XSD:

<?xml version="1.0" encoding="utf-8" ?>

<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

          <xs:element name="PayItems" type="UserList" />

          <xs:complexType name="Item">

                    <xs:sequence>

                              <xs:element name="ItemNumber" type="xs:string" />

                              <xs:element name="EstimatedQty" type="xs:int" />

                              <xs:element name="Unit" type="xs:string" />

                              <xs:element name="Description" type="xs:string" />

                              <xs:element name="ContractUnitPrice" type="xs:decimal" />

                    </xs:sequence>

          </xs:complexType>

          <xs:complexType name="UserList">

                    <xs:sequence maxOccurs="unbounded">

                              <xs:element name="Item" type="Item" />

                    </xs:sequence>

          </xs:complexType>

</xs:schema>

And this is a shortened version of the XML:

<?xml version="1.0" encoding="utf-8" ?>

<PayItems  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:noNamespaceSchemaLocation="M:\0199909.CAD\Forms\test\XML DataSource\test1.xsd">

  <Item>

    <ItemNumber>201 002 </ItemNumber>

    <EstimatedQty>1</EstimatedQty>

    <Unit>LS </Unit>

    <Description>CLEAR &amp; GRUB </Description>

    <ContractUnitPrice>500</ContractUnitPrice>

  </Item>

  <Item>

    <ItemNumber>202 002 </ItemNumber>

    <EstimatedQty>6000</EstimatedQty>

    <Unit>CY </Unit>

    <Description>COMMON EXCAVATION </Description>

    <ContractUnitPrice>15</ContractUnitPrice>

  </Item>

  <Item>

    <ItemNumber>202 004 </ItemNumber>

    <EstimatedQty>1800</EstimatedQty>

    <Unit>CY </Unit>

    <Description>HARD SURFACE PAVMT. EXCAVATION </Description>

    <ContractUnitPrice>15</ContractUnitPrice>

  </Item>

</PayItems>

Regards,

Karl S

1 Reply

Avatar

Level 10

Try the below code in the exit event of the ItemNumber dropdown with Java Script as language.

var oAllItems = xfa.resolveNodes("$record.Item[*])");

for(i=0;i<oAllItems.length;i++){
var oSelectedItem = xfa.resolveNode("$record.Item[" + i + "])");
 
      if(oSelectedItem.ItemNumber.value == this.rawValue){
            EstimatedQty.rawValue = oSelectedItem.EstimatedQty.value;
            Unit.rawValue = oSelectedItem.Unit.value;
            ContractUnitPrice.rawValue = oSelectedItem.Description.value;
      }
}

Similarly in the exit event of the EstimatedQty dropdown, place the following code.

var oAllItems = xfa.resolveNodes("$record.Item[*])");

for(i=0;i<oAllItems.length;i++){
     var oSelectedItem = xfa.resolveNode("$record.Item[" + i + "])");

          if(oSelectedItem.EstimatedQty.value == this.rawValue){
               ItemNumber.rawValue = oSelectedItem.ItemNumber.value;
               Unit.rawValue = oSelectedItem.Unit.value;
               ContractUnitPrice.rawValue = oSelectedItem.Description.value;
          }
}

Replace the code with the Proper field names. I used the same names as columns.

Thanks

Srini