Expand my Community achievements bar.

SOLVED

Display all instances of dynamic field, separated by semicolon

Avatar

Level 2

I currently have a form where I dynamically populate the To and CC fields of an automated email. First, I grab the value of the 'email' text fields in a table, and I populate another text field with it's value, then the 'submit email' button references each of the separate text fields to populate To and CC. This part works fine.

However the last row in the table is dynamic, and therefore may have multiple instances.

I don't know how to loop through the instances and grab each email separately, right now it only returns the last instance of the dynamic row's email field. This is what I have:

var countRows = Table5.RepeatingRow.instanceManager.count;

for(i=0; i<countRows; i++){

this.resolveNode("TextFieldA").rawValue = xfa.resolveNode("RepeatingRow["+ i +"].Email").rawValue + "; "

next;

}

If there are 3 instances of RepeatingRow.Email, I would like the rawValue of TextFieldA to be "email1; email2; email3" etc

any help is greatly appreciated!

1 Accepted Solution

Avatar

Correct answer by
Level 10

This should to the trick:

var oRows = Table5.resolveNodes("RepeatingRow[*]"),

cResult = "";

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

    cResult += oRows.item(i).Email.rawValue;

    if (i > 0) {

        cResult += "; ";

    }

}

// add your script to use cResult

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

This should to the trick:

var oRows = Table5.resolveNodes("RepeatingRow[*]"),

cResult = "";

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

    cResult += oRows.item(i).Email.rawValue;

    if (i > 0) {

        cResult += "; ";

    }

}

// add your script to use cResult

Avatar

Level 2

That worked like a charm radzmar!! Thank you very much for the quick reply.

For anyone else that may need to use this code, the only edit I made was in this line:

(i > 0)

changed to

(i >= 0)

I failed to mention in my first post that I start with one instance -- so when I first tried the code it would combine the initial and first instance, then separate the others -- eg "email1email2; email 3; email 4"

This is a much more efficient way of doing it too