Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

specifying an instance of a repeatable row

Avatar

Level 3

I am trying to bind the data between two fields that are both repeatable. Basically, I have a table with a repeatable row, and in this row the user will enter a part name and a part number and various other information. They will also specify wither the part is "New" or "Change." For each part that is marked as "Change," I add an instance to a repeatable table on another page of the form (this table is only present for parts marked as "Change," so if I have five rows in the first table and only three parts are marked as "Change," then I should have three instances of the table on page two). This is all well and good, but the tables on the second page should have a field for part name and part number that matches what is in the corresponding row on page 1. Initially, I wrote a for loop that set the value of the fields in the first instance of the table on page two to the value of the fields in the first instance of the row on page one. However, this won't work because it does not take into account whether the row is marked as "Change" or "New." Is there a way to evaluate or identify something as the first instance where a value is true or false? e.g. - make a field equal to the first instance of a row where a condition is true\

the code I am currently using is:

for (i = 0; i < DispositionTable_1._Row1.count; i++) {

    if (this.parent.index === i) {

        this.resolveNode("form1.ECO_Table_subform.ECO_table[" + i.toString() + "].Change_1.Change_1_header.PN1").rawValue = this.resolveNode("$").rawValue;       

    }

}

and I also tried this (but it didn't work):

for (i = 0; i < DispositionTable_1._Row1.count; i++) {

    if ((this.parent.index === i) && (this.resolveNode("form1.Disposition_table_subform.DispositionTable_1.Row1[" + i.toString() + "].change_checkbox").rawValue == "1") {

        this.resolveNode("form1.ECO_Table_subform.ECO_table[" + i.toString() + "].Change_1.Change_1_header.PN1").rawValue = this.resolveNode("$").rawValue;       

    }

}

2 Replies

Avatar

Level 10

Hi,

I am not sure where the code you have shown is being used, but you could try using the calculate event of the second table, this would give you some code like;


_Row1.setInstances(0);

var rowCount = Table1._Row1.count;

var rows = Table1.resolveNodes("Row1[*]");

for (var i = 0; i < rowCount; i++)

{

    var row = rows.item(i);

    if (row.NewChange.rawValue === "Change")

    {

        var secondTableRow = _Row1.addInstance(true);

        secondTableRow.PN1.rawValue = row.PN1.rawValue;

    }

}

Here is a link to an example, I hope it helps https://sites.google.com/site/livecycledesignercookbooks/home/a.c.hoff.pdf?attredirects=0&d=1

Regards

Bruce

Avatar

Level 2

I'd go for something like this on the exit event of the last field in Row 1:

var objWhere1 = xfa.resolveNode("Row1[" + (_Row1.count - 1) + "]");

var objWhere2;

_Row1.addInstance();

if (objWhere1.change_checkbox.rawValue == "1")

{

  _Row2.addInstance();

  objWhere2 = xfa.resolveNode("Row2[" + (_Row2.count - 1) + "]");

  objWhere2.PN1.rawValue = objWhere1.PN1.rawValue;

  objWhere2.PN2.rawValue = objWhere1.PN2.rawValue;

}