Display all instances of dynamic field, separated by semicolon

SafetyMan1989

06-11-2018

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!

Accepted Solutions (1)

Accepted Solutions (1)

radzmar

MVP

06-11-2018

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

Answers (1)

Answers (1)

SafetyMan1989

06-11-2018

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