Copy link to clipboard
Copied
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?
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.
Copy link to clipboard
Copied
Thank you, I'll try there.
Copy link to clipboard
Copied
Ah. Thank you! I was putting them all in separate quoatation marks.
Copy link to clipboard
Copied
I have tried the same above per instruction(I am submitting the whole sheet) and it does nothing once I have modified the script with my field names. I do have required fields for all 3 fields in my code below:
var targetEmail = " bryanc@xxx.com;?cc=jamiem@xxx.com;heathers@xxx.com";
var subjectLine = this.documentFileName + " " + this.getField("Unit Number").valueAsString + " " + this.getField("Ordered by").valueAsString + " " + this.getField("Order Date").valueAsString;
var body = "Please fill out form completely and with as much information as you can. Thanks.\nThis is a new line of text.";
this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body}):
What am I missing?
Copy link to clipboard
Copied
The CC address(es) needs to be specified using the cCc parameter. Also, drop the space at the start of the targetEmail variable. And check the JS Console for errors once you run the code.
Copy link to clipboard
Copied
Thanks. That was it!
Copy link to clipboard
Copied
Hi Try67,
I have tried a few combinations and the javascript does not work for me.
var targetEmail = "XXX@sever.com";
var subjectLine = this.documentFileName + " " + this.getField("Change No.").valueAsString + " " + this.getField("Permit Holder (Supervisor of the Work").valueAsString + " " + this.getField("Last").valueAsString;
var body = "The permit has been signed off.\nThis is a new line of text.";
this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body});
What am I missing?
Copy link to clipboard
Copied
Check the JavaScript console for errors.
Copy link to clipboard
Copied
Hi Try67 (i know your name from previous encounters, but I am not sure I should use it here.
I have adapted the basic script in this string to get the proper subjectline based on my form. I can also add a body line, but I would like it to appear before the actual form, rather than at the end of the body of the email. (In this case the message is "Here is my application. Thank you."
See images. Is there a way to do this? Thanks, Stuart
Copy link to clipboard
Copied
Actually, I still have a bit of a problem because when I open the pdf, it immediately gives me a box to send an email before I have actually completed the form....How do I fix that?
Copy link to clipboard
Copied
Try this:
va targetEmail = "pacifictransportationassoc@gmail.com";
var subjectline = this.documentFileName + " " + this.getField("PTA Membership Application Renewal form").valueAsString + " " + this.getField("Name 1").valueAsString;
var body = "Here is my completed application. Thank you";
this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body});
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This script works to add the form to the outgoing email and adds the proper subject line. I guess I can dispense with the message in the body. But my problem is this: I open the document the first thing that happens is a cue to send email, before the form opens to allow people to fill it in.
This will be distributed to people and they should not confront this confusing email message until they have seen and completed the form. How can I eliminate that first email box and open the form directly?
//------------------------------------------------------------- //-----------------Do not edit the XML tags-------------------- //------------------------------------------------------------- //<Document-Level> //<ACRO_source>Email Response</ACRO_source> //<ACRO_script> /*********** belongs to: Document-Level:Email Response ***********/ var targetEmail = "pacifictransportationassoc@gmail.com"; var subjectLine = "PTA Membership Application Renewal from " + this.getField("Name 1").valueAsString; var body = "Enter the message body here.\nThis is a new line of text.";
this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body}); //</ACRO_script> //</Document-Level>
Copy link to clipboard
Copied
You need to place the script somewhere else, then. What do you want to trigger it?
Copy link to clipboard
Copied
PS. Do NOT edit the code via the Edit All JavaScripts window! You can seriously mess up your file if you do.
Copy link to clipboard
Copied
I'm sorry, I don't know enough about this to understand your answer. I created a document java script, but then I don't know how to apply this script to a button...I see no way to select this particular script. ANd I am not even sure this it the right way to do it.
It might be better if you can point me to some sort of tutorial, rather than try to go back and forth with this, given my limited knowledge.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Remove the code from the doc-level script and place it under the Action of your Link object. It's that simple.
Copy link to clipboard
Copied
Worked!...thanks.