Create list or array for submit form message body
Copy link to clipboard
Copied
I'm trying to add to the message body of a submit.form but wanting to refine my code. I have four fields per line and want to output those if the first of the fields "DIU Item [n] is filled.
DIU Item 1, DIU Item 1 Qty Used, DIU Item 1 Open Not Used, DIU Item 1 Qty Needed
Is there a way to create a loop that would use an array or list that would allow for the format "Item: "+DIU Item 1+" Qty Used: "+DIU Item 1 Qty Used+ " Open Not Used: "+DIU Item 1 Open Not Used+" Qty Needed: "+DIU Item 1 Qty Needed+"\n"
I want to only grab the fields that have data.
Copy link to clipboard
Copied
Sure, that's possible. Say you have 20 such lines. You can use this code to create the string with all of their values:
var msgBody = "";
for (var i=1; i<=20; i++) {
if (this.getField("DIU Item "+i).valueAsString!="")
msgBody+="Item: "+this.getField("DIU Item "+i).valueAsString+" Qty Used: "+this.getField("DIU Item "+i+" Qty Used").valueAsString+ " Open Not Used: "+this.getField("DIU Item "+i+" Open Not Used").valueAsString+" Qty Needed: "+this.getField("DIU Item "+i+" Qty Needed").valueAsString+"\n";
}
Copy link to clipboard
Copied
This looks so very right. I can't wait to try it.

