Expand my Community achievements bar.

SOLVED

referencing an object in a repeating subform

Avatar

Level 1

I'm trying to have the value of a text field in a repeating subform (lets call it the “Identify” subform) of my form to be set to the value of “TextField18” in the corresponding subform instance of the “Groups” subform.

In more detail:

In the form I ask the question - how many groups do you have? The number for that answer is the number of instances of the "Groups" subform that I have. Within that subform is a text field ("Text Field18")  where the user would enter the name of the group.

Later, in a completely different section of the same form, I have a subform called "Identify". I have figured out how to set the number of instances of "Identify" to match the number of instances of "Groups". What I would like to do is have a field in "Identify" display the name of each group (as entered in "TextField18" in the "Groups" subform) - one per instance of the subform.  So if the groups were Orange, Red and Purple as entered in instances 1-3 respectively of the "Groups" subform. I would want the field in instance 1 of the "Itentify" subform to autopopulate with Orange, and the field in instance 2 to autopopulate with Red, and so on.

Is this possible?  Any advice is appreciated!


1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Your repeating subforms, Groups and Identify, will have an index property to identify their occurance.  So in the calculate event of the textfield in Identify using JavaScript place the following code;

 

xfa.resolveNode("Groups["+Identify.index+"].TextField18").rawValue;

This will return the corresponding value in the Groups subforms.  Note you may have to adjust the SOM expression if Groups and Identify are not at the same level.

Bruce

View solution in original post

3 Replies

Avatar

Level 7

You access each instance of the Groups subform in formcalc by using Groups[0].TextField18, Groups[1].TextField18 etc. (remembering the numbers start at 0 not 1). So to fill your Identify fields you would do a loop with a variable to access each instance and then fill the field with the relevant instance of TextField18.

Avatar

Correct answer by
Level 10

Hi,

Your repeating subforms, Groups and Identify, will have an index property to identify their occurance.  So in the calculate event of the textfield in Identify using JavaScript place the following code;

 

xfa.resolveNode("Groups["+Identify.index+"].TextField18").rawValue;

This will return the corresponding value in the Groups subforms.  Note you may have to adjust the SOM expression if Groups and Identify are not at the same level.

Bruce

Avatar

Level 1

Thank you both for your help.

I'd done everything with JavaScript so far, so I tried Bruce's answer and it worked perfectly!