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

Count dropdown objects in repeating subform if user selects "N/A".

DKinsley
Level 9
Level 9

I am trying to count the number of dropdowns the user selected "N/A" in a repeating subform. I want the total to appear in a numericfield or textfield. Here's my form layout and my script that unfortunitly does not work. I placed it in the ready:layout event so the total updates as the number of N/A's changes.

Hierarchy.GIFScript.GIF

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

I would put the code in the calculate event of the text field, something like;

var result = 0;

var instanceCount = _Subform2.count;

var instances = Form1.resolveNodes("Subform2[*]");

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

{

  if (instances.item(i).Table1.Row2.Score.rawValue == "N/A") {

  result++;

  }

}

this.rawValue = result;

The reference to "_Subform2.count" will ensure the code is executed every time an instance is added or removed.

Regards

Bruce

View solution in original post

2 Replies
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

I would put the code in the calculate event of the text field, something like;

var result = 0;

var instanceCount = _Subform2.count;

var instances = Form1.resolveNodes("Subform2[*]");

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

{

  if (instances.item(i).Table1.Row2.Score.rawValue == "N/A") {

  result++;

  }

}

this.rawValue = result;

The reference to "_Subform2.count" will ensure the code is executed every time an instance is added or removed.

Regards

Bruce

View solution in original post

DKinsley
Level 9
Level 9

Thank you so very much!

Works great!