Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to submit to email with specific fields in subject line?

New Here ,
Mar 16, 2018 Mar 16, 2018

I've got a pdf created with a submit button. it works, but I would like to collect information in a field of the PDF and include it in the subject line of the email.

Ex: I need to collect the Users name field to be included in the subject line of the email.

Is this possible?

TOPICS
PDF forms
18.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 16, 2018 Mar 16, 2018

OK, then remove the Submit Form command you added to the button and add a Run a JavaScript command instead, with this code:

var targetEmail = "me@server.com";

var subjectLine = this.documentFileName + " " + this.getField("First").valueAsString + " " + this.getField("MI").valueAsString + " " + this.getField("Last").valueAsString;

this.mailDoc({cTo: targetEmail, cSubject: subjectLine});

Of course, change the target email address in the first line to the actual one you want to use.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2018 Mar 16, 2018
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2018 Mar 16, 2018

Thanks, but I don't know much about scripts. I read through it but can't figure out how to, or where to add that to the submit button properties.

The Submit button automatically adds the file name to the Subject Line of the email. I need to pull three fields: First, MI, Last and add it to the end of that.

I also would like to remove "Form Returned" from the subject . . . . . I'm getting close to having a great process in place . . . .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2018 Mar 16, 2018

Are you submitting the whole form, or just the form data? Are you relying on the validation of the required fields?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2018 Mar 16, 2018

I want to submit the entire form as a PDF. This is a form that multiple people will be completing. I wanted to collect the Users name in the subject line so when it arrived it would be easier to keep up with. The email is actually sending this form into ServiceNow and creating tickets. User names will be invaluable for us in tracking the tickets.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2018 Mar 16, 2018

And the answer to my other question?...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2018 Mar 16, 2018

Sorry,

No validation, just whatever is typed into the name field to be added to the subject line

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2018 Mar 16, 2018

OK, then remove the Submit Form command you added to the button and add a Run a JavaScript command instead, with this code:

var targetEmail = "me@server.com";

var subjectLine = this.documentFileName + " " + this.getField("First").valueAsString + " " + this.getField("MI").valueAsString + " " + this.getField("Last").valueAsString;

this.mailDoc({cTo: targetEmail, cSubject: subjectLine});

Of course, change the target email address in the first line to the actual one you want to use.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2018 Mar 16, 2018

Cool!

by golly, I think that did it!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2018 Mar 16, 2018

Looks like that removed the body text as well. Do I add "var body = what i want in the body" ??

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2018 Mar 16, 2018

Almost. Use this:

var targetEmail = "me@server.com";

var subjectLine = this.documentFileName + " " + this.getField("First").valueAsString + " " + this.getField("MI").valueAsString + " " + this.getField("Last").valueAsString;

var body = "Enter the message body here.\nThis is a new line of text.";

this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body});

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2018 Mar 16, 2018

You're the BEST!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 07, 2019 Dec 07, 2019

Is there a way to send to multiple email addresses using this script? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 07, 2019 Dec 07, 2019

Sure. Just change this line:

var targetEmail = "me@server.com";

To something like this:

var targetEmail = "me@server.com;john@server.com;jane@server.com";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 10, 2023 Aug 10, 2023

For line 3: var body = "Enter the message body here.\nThis is a new line of text.";

How can I change this to include "this.getField" to show specific fields in the body of the email? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2023 Aug 10, 2023

Like this:

 

var body = "Enter the message body here.\nThis is a new line of text\nSent by: " + this.getField("Name").valueAsString;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 10, 2023 Aug 10, 2023

Thank you! What if perhaps I needed to add a secondary line to the body of the email, something like this?

 

var body = "New Sales Order.\nPlease enter and prepare to ship\nOrdered By: " + this.getField("Ship To").valueAsString " + this.getField(“Other Comments or Special Instructions”).valueAsString;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2023 Aug 10, 2023

You just need to add the "\n" where you want the line-break to appear. For example:

var body = "New Sales Order.\nPlease enter and prepare to ship\nOrdered By: " + this.getField("Ship To").valueAsString " + "\n" + this.getField("Other Comments or Special Instructions").valueAsString;

 

You need to make sure your code only has straight-codes, though, not curly ones like your example above.

Do NOT use Word as a code editor. Only use a plain-text editor, like Notepad++.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2023 Aug 02, 2023

Thank you so much for your answer. It worked for me. Is there any way to automatically rename the attached file as well?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Only if you can install a script file on the machine of each user who will be using it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 21, 2023 Sep 21, 2023

Hi @try67,

I'm wondering if there's a way to include the entire code within the "mailto:" line? My concern is that I have required fields, and I'd like to prevent the form from being submitted when those fields are empty.

 

Thank you 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2023 Sep 21, 2023

No, but you can use a script to perform that validation yourself, before submitting the file.

I've posted code that does that to this forum multiple times. Search "validateRequiredFields".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 21, 2023 Sep 21, 2023

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 07, 2023 Nov 07, 2023

Would this work the same way for an Adobe sign web form? I'd like my web form when submitted and an email is received that the subject line includes the name of the document and a name field from the form to easily identify who filled out the web form.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 07, 2023 Nov 07, 2023

I doubt it, as such forms have little to no support for scripts, but you can try asking in the Acrobat Sign forum.

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