Javascript help: submit button to use form field plus other text in Subject line

Explorer ,
Feb 21, 2020

Copy link to clipboard

Copied

I have a form for which I made a Submit button.

It will be sending the form to two different email addresses.

I was able to find examples of javascript so I can use one of the form's fields as a subject line, however I would also like to have some other text in the subject as well, and I just can't seem to figure out how to add that.

this.mailDoc({cTo: "email_1;email_2", cSubject: this.getField("full_name").valueAsString});

Before "full_name" I'd like to have the Title Of Form. So the email subject like would be "Title of Form_full_name"

I can't seem to get that to work... do I make it:

cSubject="Title of Form_" this.getField("full_name").valueAsString});

?

Please help.

TOPICS
Acrobat SDK and JavaScript, Create PDFs, How to, PDF forms

Views

63

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Javascript help: submit button to use form field plus other text in Subject line

Explorer ,
Feb 21, 2020

Copy link to clipboard

Copied

I have a form for which I made a Submit button.

It will be sending the form to two different email addresses.

I was able to find examples of javascript so I can use one of the form's fields as a subject line, however I would also like to have some other text in the subject as well, and I just can't seem to figure out how to add that.

this.mailDoc({cTo: "email_1;email_2", cSubject: this.getField("full_name").valueAsString});

Before "full_name" I'd like to have the Title Of Form. So the email subject like would be "Title of Form_full_name"

I can't seem to get that to work... do I make it:

cSubject="Title of Form_" this.getField("full_name").valueAsString});

?

Please help.

TOPICS
Acrobat SDK and JavaScript, Create PDFs, How to, PDF forms

Views

64

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 21, 2020 0
Adobe Community Professional ,
Feb 21, 2020

Copy link to clipboard

Copied

You concatonate strings like this:

cSubject="Title of Form_" + this.getField("full_name").valueAsString});

The "+" is the concatonation operator.

Here's an article on string manipulation in JavaScript. It shows a few different ways to build strings:

 https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/

 

Here's an article on setting up email properties from a script. It also shows how to maniuplate strings:

https://www.acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address/

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 21, 2020 0
Explorer ,
Feb 21, 2020

Copy link to clipboard

Copied

I'm getting an error:

SyntaxError: missing : after property id
1:

Thanks, I'll keep plugging away.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 21, 2020 0
Explorer ,
Feb 21, 2020

Copy link to clipboard

Copied

Ah! Got it!

cSubject:"Title of Form_" + this.getField("full_name").valueAsString});

colon instead of first equal sign

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 21, 2020 0
Adobe Community Professional ,
Feb 21, 2020

Copy link to clipboard

Copied

Correct, the code fragment was out of context, so I missed a couple of bits there. Good Catch!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 21, 2020 0