Skip to main content
Inspiring
May 10, 2023
Answered

Email Javascript Submit Button

  • May 10, 2023
  • 5 replies
  • 6189 views

I would like to to pull a name from a form field on my forms and place it where (add name from a form field here) in the script below. The script works perfectly as is, I would just like to add the name to each section. Can someone please help? Thanks

 

this.mailDoc({ cTo: "joeblow@myemail.com",


cSubject: "My Form for (add NAME from a form field here)",cMsg: "Please see the attached form in reference to (add NAME from a form field here) ."

 

});

 

This topic has been closed for replies.
Correct answer JR Boulay

Try this:

 

var str1 = this.getField("FirstName").valueAsString;
var str2 = this.getField("MiddleName").valueAsString;
var str3 = this.getField("LastName").valueAsString;
var sMsg = "Please see the attached Inquest Summary Report/Autopsy Authorization in reference to the death of " + str1 + " " + str2 + " " + str3 + ". If you have any questions, please feel free to contact my office. Thank you!"
var sSubject = "My Form";
this.mailDoc({ cTo: "joeblow@myemail.com", cSubject: sSubject ,cMsg: sMsg});

5 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
May 17, 2023

Try this:

 

var str1 = this.getField("FirstName").valueAsString;
var str2 = this.getField("MiddleName").valueAsString;
var str3 = this.getField("LastName").valueAsString;
var sMsg = "Please see the attached Inquest Summary Report/Autopsy Authorization in reference to the death of " + str1 + " " + str2 + " " + str3 + ". If you have any questions, please feel free to contact my office. Thank you!"
var sSubject = "My Form";
this.mailDoc({ cTo: "joeblow@myemail.com", cSubject: sSubject ,cMsg: sMsg});

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
May 17, 2023

Thank you for your response again. For some reason it will not pull the form fields into the email. I have the fields labeled exactly like in the code.

Inspiring
May 17, 2023

And the console has no errors. 

Inspiring
May 16, 2023

This is the javascript that I would actually like to have if you could help me figure out how to pull the First, Middle, and Last name from the form fields in the pdf form. Each name has it's own field and are titled (FirstName) (MiddleName) (LastName). For some reason, the script will not recogzine the field name. This script works perfectly except it will not pull the fields into the message. Thank you!

 

this.mailDoc({ cTo: "joeblow@myemail.com",


cSubject: "Justice of the Peace Inquest Summary Report/Autopsy Authorization",cMsg: "Please see the attached Inquest Summary Report/Autopsy Authorization in reference to the death of (First Name) (MiddleName) (LastName). If you have any questions, please feel free to contact my office. Thank you!"

 

});

JR Boulay
Community Expert
Community Expert
May 12, 2023

The Console says your made a typo in the field's name.

JavaScript is case sensitive.

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
May 12, 2023

Thank you for your response. I will see if that works

Inspiring
May 16, 2023

I double checked the spelling of the form field name and still getting the same response in the console. It's still not recognizing the form field name. Thanks for any help with this.

Legend
May 11, 2023

1. Where exactly did you enter this code, and how did you run it?

2. Was there anything in the JavaScript console?

Inspiring
May 11, 2023

I entered the code in the action tab with javascript. 

Legend
May 11, 2023

And... question 2 please. 

JR Boulay
Community Expert
Community Expert
May 11, 2023

Try this, after adjusting the field name:

 

var sName = this.getField("name").valueAsString;
var sSubject = "My Form for " + sName;
var sMsg = "Please see the attached form in reference to " + sName + ".";
this.mailDoc({ cTo: "joeblow@myemail.com", cSubject: sSubject ,cMsg: sMsg});

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
May 11, 2023

Thanks for your reply. I entered the code and replaced "name" with my form field name but nothing happened.