Expand my Community achievements bar.

Create a script that will Email Subject from Text Field

Avatar

Level 1

Hello,

I am new to scripting.  Please bare with me.....  i've got my form all set. 

I am looking to have the user click on the "send email" button I created.  Then it will take the data the user entered in a text field (last name) of the form and put that into the subject line of the email before they send it.

So the suject line should read something like:  New User - Williams

i have scoured the forums and found some help but not in full.  I found the scripting section but don't know how to create it or what the script should look like.

Any help would be greatly appreciated.

Thank you for your patience!

1 Reply

Avatar

Level 6

Hi michael

Create a new button, and select "Regular" as the Control Type

Using javascript, add this code to the button's click event:

//Can messageBox text below, if needed

var choice = xfa.host.messageBox("Press OK to submit this form via email, and follow any on-screen instructions", " ", 3, 1);

//If user selects "OK", proceed with email...

if (choice == 1){

var mail;

//default email address where form is to be returned

var address = "email@email.com";

//Build subject line; grab last name field value (update field location/path, as required)

var sub = String.concat("New User - ", form1.Page1.LastName.rawValue);

//Add default text in email body if desired

var body = "Enter Body message here";

//Build email message

mail = "mailto: " + address + "?subject=" + sub + "&body=" + body;

event.target.submitForm({

cURL: mail,

bEmpty: true,

cSubmitAs: "PDF",

cCharset: "utf-8"

});

}

else{

}

NOTE: You will need to make the form Reader Enabled so Adobe Reader users are able to use this as well.