Skip to main content
et1mark
Participating Frequently
January 14, 2023
Question

Create list or array for submit form message body

  • January 14, 2023
  • 1 reply
  • 593 views

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.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 15, 2023

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";
}
et1mark
et1markAuthor
Participating Frequently
January 19, 2023

This looks so very right.  I can't wait to try it.