Skip to main content
Participant
April 30, 2020
Answered

Custom Subject line in Java Script

  • April 30, 2020
  • 1 reply
  • 1195 views

I built a button on a form to email the entire .pdf back for review. I figured out how to program the button to execute a Java script that will pull data from a field and display it in the Subject line of the email.

var mySubject=this.getField("Traveler Name").value;

this.mailDoc({bUI: true, cTo: "corporate.security@mycompany.com", cSubject: mySubject})

What I can't seem to figure out is how to edit the script to include the text, "Business Essential Travel Request from: " to precede the [Traveler Name] field in the Subject line:

 

PS: I have NO Java KSA's.

This topic has been closed for replies.
Correct answer Thom Parker

In JavaScript, Text is concatonated just like numbers are added.

 

var mySubject= "Business Essential Travel Request from: " + this.getField("Traveler Name").value;

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 30, 2020

In JavaScript, Text is concatonated just like numbers are added.

 

var mySubject= "Business Essential Travel Request from: " + this.getField("Traveler Name").value;

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
whcarver6Author
Participant
April 30, 2020

var cSubLine = "Business Essential Travel Request for " + this.getField("Traveler Name") .value;
this.mailDoc({bUI: true, cTo: "corporate.security@mycompany.com", cSubject: cSubLine})

 

thoughts?

Thom Parker
Community Expert
Community Expert
April 30, 2020

Do you have a question?

The code looks good.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often