• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Create list or array for submit form message body

New Here ,
Jan 14, 2023 Jan 14, 2023

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.

TOPICS
Create PDFs , JavaScript

Views

308

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2023 Jan 15, 2023

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";
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines