These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Change email subject based on field data

kbedward
Registered: Nov 9 2007
Posts: 29
Answered

I have a PDF form created in Acroforms 8 which has a button with the following code

this.mailDoc ({
cTo:
"New Site Construction - IT,",
cSubject: "New Site Setup",});

The button works fine but I would like to add the site name to the subject line based on what is entered in the "Site" text field.

My Product Information:
Acrobat Pro 8.1.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can acquire the value of a field with code like this:

var cSite = this.getField("Site").value;

Then Apply it to the mail function like this:

this.mailDoc({...., cSubject: cSite });

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kbedward
Registered: Nov 9 2007
Posts: 29
Thanks Thom. What if I want the site name added to additional text in the subject line. Where would I put the cSite in the code?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Just add the text to "cSite". Here's a basic string concatonation operation. If you write much JavaScript in Acrobat, you'll be doing this a lot.

var cSite = ...;
var cMsg = "New Site Setup: " + cSite; // Text Concatonation
this.mailDoc({...., cSubject: cMsg });

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kbedward
Registered: Nov 9 2007
Posts: 29
That's Great!!!!

I changed the code to the following and it works like a charm!

var cSite = this.getField("Site").value;
var cMsg = "New Site Setup: " + cSite; // Text Concatonation
this.mailDoc ({
cTo:
"New Site Construction - IT, ",
cSubject:cMsg,});