Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Possible to fill 2 different table dependent on the data input

Avatar

Level 2

Hi community,

is it possible in Adobe Lifecycle Designer to fill two different tabels  based on the data input?

I'm creating a form in Adobe Lifecycle Designer with data binding for usage in our CRM System. This form should show 2 tables. The tables are dynamically growing dependent on the data. In each column is a data binding to the respective field maintained. Also a relative data binding in the growing row is defined that the data is shown in regard to the Item ID. My scenario is that I want to display the data in two different tables dependent on the data input of the product field. So one table for Product A and another one for product B.

Table Product A

ITEM IDPRODUCTTECHNICIANCUSTOM1CUSTOM2CUSTOM3
10PRODUCT APERSON 1TESTTESTTEST
20PRODUCT APERSON 2TESTTESTTEST

Table Product B

ITEM IDPRODUCTTECHNICIANCUSTOM1CUSTOM2
30PRODUCT BPERSON 1TESTTEST
40PRODUCT BPERSON 2TESTTEST

The data binding looks like this:

  • data binding of the DataRow (growing row in the table): $.ServiceRequest.Item[*]
  • data binding of the Item ID: $.ServiceRequest.Item[*].ID
  • data binding of the Product: $.ServiceRequest.Item[*].Description

I tried to use the following scripting in the data row of the validate/initialize event:

  • for table Product A: -->address the procdut data via the SOM name and request the condition ever item equals Product A, should be displayed.

if (FormServiceRequestConfirmation.Page2.frmKilometer.TableKilometer.DataRow.txtProduct.rawValue == "Product A")

then

   this.rawValue = xfa.record.ServiceRequest.Item[*].Description.value;

endif

  • for table Product B

if (FormServiceRequestConfirmation.Page2.frmKilometer.TableKilometer.DataRow.txtProduct.rawValue == "Product B")

then

   this.rawValue = xfa.record.ServiceRequest.Item[*].Description.value;

endif

Currently, it's not working. The first table shows all items and the second none. I also tried to hide the items in table Product A that belong to table B with (this.presence = "hidden";), but then the data belonging to product B isn't in the second table...

What's wrong in my script? How does it has to look like? - Can you help me Bruce BR001​? I highly appreciate your inputs

Thanks very much for help and best regards,

Deborah

4 Replies

Avatar

Level 2

I managed to get table A to show only Product A items. I used the following code in the table initialize event (FormCalc):

//Number of repeated DataRows (-1 because count from zero)

var vRows = Form.Page2.frmProductA.TableProdA.DataRow.instanceManager.count-1;

//Count Down-Loop deleting every Row that is not a Product A Item (product unequal "A")

for i=vRows downto i >= 0 do

if (Form.Page2.frmProductA.TableProdA.DataRow[i].txtProduct ne "A")

then

Form.Page2.frmProductA.TableProdA.DataRow[i].presence = "hidden"

endif

endfor

But now I still have the issues that I inserted the same code/logic for table TableProdB, but at the moment the second table TableProdB is still completely empty.

Is this because I have hidden the Product B data in the first table TableProdA?? Does anyone have an idea how to solve this? BR001

Best regards,

Deborah

Avatar

Level 4

Without scripting it is (almost) impossible to fill two tables with the same XML data: You can bind your data "by name" (which you usually avoid, as it is unsafe in the longrun). You can duplicate your data in your XML. Or you can duplicate your XML data with XSLT.

Or you script: Basically for every row being added during the XML import in the first table you add a row in the second table and copy your data there.

Avatar

Level 2

Hi ulibaehr​,

can you please provide an sample script? Or which function do I have to use in the script?

I found this: (probably JavaScript) -->how is the syntax in FormCalc?

     getField("text2").value = getField("text1").valueAsString;

I changed my code by adding a loop to copy the values to the second Table (TableProdB). See below:

      Form.Page2.frmProductA.TableProdA::initialize - (FormCalc, client)

     //Number of repeated DataRows (-1 because count from zero)

     var vRows = Form.Page2.frmProductA.TableProdA.DataRow.instanceManager.count-1;

     //add as much instances as TableProdA has to TableProdB

     Form.Page2.frmProductA.TableProdA.DataRow.instanceManager.addInstance(vRows);

     //Count Down-Loop copying the values to from TableProdA to TableProdB

     for i=vRows downto i >= 0 do

     getField("Form.Page2.frmProductA.TableProdA.DataRow[i].txtID").value =      getField("Form.Page2.frmProductA.TableProdB.DataRow[i].txtTechnician").valueAsString;

     getField("Form.Page2.frmProductA.TableProdA.DataRow[i].txtCustom1").value =      getField("Form.Page2.frmProductA.TableProdB.DataRow[i].txtCustom2").valueAsString;

    endfor

     //Count Down-Loop deleting every Row that is not a Product A Item (product unequal "A")

     for i=vRows downto i >= 0 do

         if (Form.Page2.frmProductA.TableProdA.DataRow[i].txtProduct ne "A")

         then

         Form.Page2.frmProductA.TableProdA.DataRow[i].presence = "hidden"

         endif

     endfor

But unfortunately it's not working....

Best regards,

Deborah

Avatar

Level 4

Deborah,

I almost never use Formcalc. It lacks some features - and you find sample scripts almost only for JavaScript.

In my next book („XML und Scripting – SAP Interactive Forms und Adobe LiveCycle Designer", espresso Verlag) you can find this funktion (here is a sneak preview). Hope it helps:

function copyTable(oMasterTable, bIgnoreBindingName ) {

// Purpose:

//    In case there are duplicates of the table oMasterTable in the form

//    then this function copies oMasterTable to these duplicates.

//    The duplicates must have the exactly same structure. All subform- and field names must be identical.

//    When is this function necessary?

//    If you fill a table with an XML file as it is impossible to fill more than one table with an XML file.

//    (It is possible to fill several tables if their bindings are "by name".)

// Parameters:

//      oMasterTable:         the subform encapsulating the repeating subform within (the repeating subform is the table row)

//      bIgnoreBindingName:   to identify the other duplicate tables correctly you can also compare the table's bindings

//                            (it might be possible to have subforms with other binding names. They would not be filled it

//                            you set this parameter to "false"

// Result:

//                      always returns true

// Usage:

//                      the function call should be placed in oMasterTable's form-ready event and might look something like this:

// Tablerow.copyTable(this, true);

// Prerequisites:

//                      The duplicate tables must have the same same structure as oMasterTable

//    

// Author:              Ulrich Bähr (paperless-process.de), 20.12.14

     //+-----------------------

     //| Find oMasterTable's repeating subform:

     //+-----------------------

     // now we look for rows or repeating subforms. They must be direct child-nodes of the table-subform node:

     var oMasterRow;

     for (var iIndexChildObject = 0; iIndexChildObject < oMasterTable.nodes.length; ++iIndexChildObject) {

           var oMasterChild = oMasterTable.nodes.item(iIndexChildObject);

           if (oMasterChild.isContainer && oMasterChild.className == "subform") {              // this node appears to be a subform. It should be page.

                 if (oMasterChild.occur != "") {

                       // the child is a repeating subform. Headers, "overflowLeaders" and such are also repeating subforms.

                       if (oMasterChild.assist.role == "" || oMasterChild.assist.role != "TH") { // Headers look like this in XML: <assist role="TH"/>

                             oMasterRow = oMasterChild;

                             oMasterRowName = oMasterChild.name;

                             break;

                       } // if oMasterChild is not a header

                 } // if oMasterChild is a repeating subform

           } // if oMasterChild.isContainer

     } // for iIndexChildObject      

           

     //+-----------------------

     //| Find all tables with the same name as oMasterTable

     //+-----------------------

     arrayOtherTables = new Array();

     arrayTables = oMasterTable.all;

     for (var i = 0; i < arrayTables.length; i++) {

           if ((arrayTables.item(i) != oMasterTable) &&

                 ((arrayTables.item(i).bind.ref == oMasterTable.bind.ref) || bIgnoreBindingName )) {

                

                 arrayOtherTables.push(arrayTables.item(i));   

           } // if (arrayTables.item(i) == oMasterTable)

     } // for i

    

     //+-----------------------

     //| Iterating over all other tables found:

     //|    Run thru all rows of oMasterTable and create a new row in the other table

     //+-----------------------

     for (var iOtherTable = 0; iOtherTable < arrayOtherTables.length; iOtherTable ++) {

           var oOtherTable = arrayOtherTables[iOtherTable];

          

           for (var iRow = 0; iRow < oMasterRow.instanceManager.count ; iRow++) {

                 oOtherRow = oOtherTable.resolveNode(oOtherTable.somExpression + "." + oMasterRowName + "[0]"); // here we assume that the rows in all tables have the same name

                 if (iRow > 0) oOtherRow.instanceManager.addInstance(true);

                 oTargetRow = oMasterTable.resolveNode(oOtherTable.somExpression + "." + oMasterRowName + "[" + iRow + "]");

                

                 //+-----------------------

                 //| copy the master table's row to the newly created other table's row:

                 //+-----------------------

                 oMasterRow = oMasterTable.resolveNode(oMasterTable.somExpression + "." + oMasterRowName + "[" + iRow + "]");

                 Tablerow.copyRowFields(oMasterRow, oTargetRow);

           } // for iMasterTable

     } // for iOtherTable

    

     return true;

} // function copyTable()

function copyRowFields(oMasterRow, oTargetRow) {

// Purpose:

//    Copies each field within oMasterRow to the corresponding field within oTargetRow.

// Parameters:

//      oMasterRow:       the subform containing the source values. It's fields are being copied to oTargetRow

//      oTargetRow:       the subform with the identical structure as oMasterRow.

// Result:

//      always returns true

// Prerequisites:

//                      The two subforms must have the identical structure (names of subforms and fields etc.)

// ToDo:

//                      This function is not prepared for not identical subform structures. It should check more and not assume identical structure.

//                      The function might call itself recursivly if oMasterField.isContainer to handle rows with subforms instead of plain fields.

// Author:              Ulrich Bähr (paperless-process.de), 20.12.14

     try {

           for (var iIndexChildObject = 0; iIndexChildObject < oMasterRow.nodes.length; ++iIndexChildObject) {

                 var oMasterField = oMasterRow.nodes.item(iIndexChildObject);

                

                

                 if (oMasterField.className == "field") {

                       if (oMasterField.resolveNode("ui.#checkButton") == null) {

                             // we actually copy a field's value here:

                             oTargetField = oTargetRow.resolveNode(oTargetRow.somExpression + "." + oMasterField.name + "[" + oMasterField.index + "]");

                             oTargetField.rawValue = oMasterField.rawValue;

                       } // if oMasterField is not a checkbox

                 } // is oMasterField is a field

           } // for iIndexChildObject

     } // try

     catch (e) {

           //console.println("Error: " + e);

           return false;

     } // catch

     return true;

} // function copyRowFields()