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

How can I concatenate the answer to multiple fields into another?

New Here ,
Aug 08, 2023 Aug 08, 2023

I would like to combine the following field names from my form into another field to generate a file name that users can copy and save.

  • Last_Name
  • First_Name
  • Department
  • Course_Start_Date

 

Once combined, I'd like the text to be formatted like this "Last_Name-First_Name-Department-Course_Start_Date-.pdf"

For example, "Smith-John-Finance-08 Aug 2023.pdf"

 

From what I've researched I assume that I will need to use Javascript, but I need help.

TOPICS
Comment review and collaborate Experiment , How to , JavaScript , PDF forms
398
Translate
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
1 ACCEPTED SOLUTION
New Here ,
Aug 08, 2023 Aug 08, 2023

This seems to work great:

Last_Name + "-" + First_Name + "-" + MAJCOM_COCOM + "-" + Course_Start_Date + "pdf"

var s = this.getField("Last_Name").valueAsString + "-" + this.getField("First_Name").valueAsString + "-" + this.getField("Department").valueAsString + "-" + this.getField("Course_Start_Date").valueAsString + "-" + this.getField("Course").valueAsString + ".pdf";

event.value = s.replace(/^, |, $/g, "");

View solution in original post

Translate
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 ,
Aug 08, 2023 Aug 08, 2023

This seems to work great:

Last_Name + "-" + First_Name + "-" + MAJCOM_COCOM + "-" + Course_Start_Date + "pdf"

var s = this.getField("Last_Name").valueAsString + "-" + this.getField("First_Name").valueAsString + "-" + this.getField("Department").valueAsString + "-" + this.getField("Course_Start_Date").valueAsString + "-" + this.getField("Course").valueAsString + ".pdf";

event.value = s.replace(/^, |, $/g, "");

Translate
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 ,
Aug 08, 2023 Aug 08, 2023
LATEST

Use this as custom calculation script of field where you want to show text:

var Lname = this.getField("Last_Name").valueAsString;
var Fname = this.getField("First_Name").valueAsString;
var Dep = this.getField("Department").valueAsString;
var CSD = this.getField("Course_Start_Date").valueAsString;

if(Lname&&Fname&&Dep&&CSD)
event.value = Lname+"-"+Fname+"-"+Dep+"-"+CSD+".pdf";
else
event.value = "";

Once all fields are filled, it will generate text.

Translate
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