Skip to main content
Participant
Nov 11, 2021 12:02 PM UTC
Answered

run a javascript + email subject line

Hi,
I am trying to run a javascript on a submit form button, to pull form fields to create the email subject line. It all works, apart from the fact that there are no spaces, so all the info appears such as 123456ClientNameProjectName.

Does anybody know how I can add a space between, its not critical, but it's just bugging me.

The code I am using is below, I am not very familiar with javascript, so any help much appreciated 🙂

 

var JobNumber = getField("JobNumber").value

var ClientName = getField("ClientName").value

var ProjectName = getField("ProjectName").value

this.mailDoc({ cTo: "email@address.co.uk",

cCc: "", cSubject: JobNumber + ClientName + ProjectName,

cMsg: "PLEASE ALSO ATTACH ANY SUPPORTING DOCUMENTS SUCH AS SPEC, BRAND GUIDELINES, COPY OR FURTHER INFORMATION."

 

});

This topic is closed to new replies. Start a new post to keep the conversation going.
JR Boulay
JR BoulayCorrect answer
Community Expert
Nov 11, 2021 12:11 PM UTC

Since the first field is a number you should use valueAsString instead of value.

Then, add a blank space after the string when creating the variables:

 

var JobNumber = getField("JobNumber").valueAsString + " ";

var ClientName = getField("ClientName").valueAsString + " ";

var ProjectName = getField("ProjectName").valueAsString;

this.mailDoc({ cTo: "email@address.co.uk",

cCc: "", cSubject: JobNumber + ClientName + ProjectName,

cMsg: "PLEASE ALSO ATTACH ANY SUPPORTING DOCUMENTS SUCH AS SPEC, BRAND GUIDELINES, COPY OR FURTHER INFORMATION."

});

Acrobate du PDF, InDesigner et Photoshopographe

2 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
Nov 11, 2021 12:11 PM UTC

Since the first field is a number you should use valueAsString instead of value.

Then, add a blank space after the string when creating the variables:

 

var JobNumber = getField("JobNumber").valueAsString + " ";

var ClientName = getField("ClientName").valueAsString + " ";

var ProjectName = getField("ProjectName").valueAsString;

this.mailDoc({ cTo: "email@address.co.uk",

cCc: "", cSubject: JobNumber + ClientName + ProjectName,

cMsg: "PLEASE ALSO ATTACH ANY SUPPORTING DOCUMENTS SUCH AS SPEC, BRAND GUIDELINES, COPY OR FURTHER INFORMATION."

});

Translate
Acrobate du PDF, InDesigner et Photoshopographe
Participant
Nov 11, 2021 12:34 PM UTC

amazing, thank you so much!!!

Translate