Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Dynamic Table Sum Not Calculating on Commit

redbaron07
Level 2
Level 2

I am using the below code to sum a dynamic table.  Each time I add a second "Table1.Row1" row, and select the value that would render countU ==0 true, the Livecycle form will not re-calcuate the query correctly unless I re-select the first row "Table1.Row1" countU value.  In other words, the dynamic table has two levels of expansion.  When I try to add more row under each primary row, the calculation does not automatically run.  Any suggestions?  Thanks in advance!

var sumD = 0;

var countS = this.resolveNodes("TableA.Row1[*].Subform2[*].Table1.Row1[*].MBRS");

var countT = this.resolveNodes("TableA.Row1[*].Subform2[*].Table1.Row1[*].NON");

var countU = this.resolveNodes("TableA.Row1[*].Subform2[*].Table1.Row1[*].CLC");

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

{

if(countU.item(i).rawValue==0)

{

sumD += (countS.item(i).rawValue * countT.item(i).rawValue);

}

}

sumD

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

I'm not sure I understand your structure you seem to have an inner repeating subform then a repeating table, that would be three levels.  Either way you will need to reference the instanceManager count property so the calculation script knows to run when the value changes, so something like;

var sumD = 0; 

var tableARows = this.resolveNodes("TableA.Row1[*]")

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

    var tableARow = tableARows.item(i);

    var table1Rows = tableARow.resolveNodes("Subform2.Table1.Row1[*]");

    for (var j = 0; j < tableARow.resolveNode("Subform2.Table1")._Row1.count; j++) {

    table1Row = table1Rows.item(j);

        if (table1Row.CLC.rawValue == 0) {

            sumD += table1Row.MBRS.rawValue * table1Row.NON.rawValue;

        }

    }

}

sumD;

Regards

Bruce

View solution in original post

3 Replies
Karwan_Mawlood
Level 3
Level 3

Please try to shar your form if possible, in order we can help you with you issue.

thanks.

_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

I'm not sure I understand your structure you seem to have an inner repeating subform then a repeating table, that would be three levels.  Either way you will need to reference the instanceManager count property so the calculation script knows to run when the value changes, so something like;

var sumD = 0; 

var tableARows = this.resolveNodes("TableA.Row1[*]")

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

    var tableARow = tableARows.item(i);

    var table1Rows = tableARow.resolveNodes("Subform2.Table1.Row1[*]");

    for (var j = 0; j < tableARow.resolveNode("Subform2.Table1")._Row1.count; j++) {

    table1Row = table1Rows.item(j);

        if (table1Row.CLC.rawValue == 0) {

            sumD += table1Row.MBRS.rawValue * table1Row.NON.rawValue;

        }

    }

}

sumD;

Regards

Bruce

View solution in original post

redbaron07
Level 2
Level 2

Thanks Bruce,

It was the instance manager - I used the exeCalculate( ) in another part of the form, and tested it with an app.alert to ensure the rows were then counting the number of instances correctly to perform the calculation properly.