Submit a Completed Form using JavaScript
Copy link to clipboard
Copied
I created a Submit button using a JavaScript to attach the form to the email so I can have a custom Subject Line and Body to the email. I just can't figure out how to get the pdf attachment as the "completed form", as it attaches the fillable form.
So basically I want to combine the "submit a form" Action but being able to still have the custom subject line and email body.
Is this even possible? Thank you in advance.
Here is the script I am using:
var targetEmail = "customemail@email.com";
var subjectLine = this.getField("Full Name").valueAsString + " " + this.getField("Acct#").valueAsString + " - " + this.documentFileName;
var body = "Funds Request\nNEEDED BY: " + this.getField("Needed By_af_date").valueAsString;
this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body});
Copy link to clipboard
Copied
What do you mean? Does it not attach the full PDF to the generated email with this code? It should...
Copy link to clipboard
Copied
It does. With the script, the form is still fillable. But when I do the "create link" with an email or something and have "submit a form" Action, it attaches it as completed (no longer fillable).
Copy link to clipboard
Copied
Ah OK, now I understand. You can set all the fields as read-only before submitting the file, but that is not secure at all. Another option is to digitally sign the file before sending it, which can be used to lock the fields.
I'm surprised that sending the file as a link would "lock" it. It should not do that. Maybe it's the result of viewing the file in a browser window, but if you open it in Acrobat or Reader the fields in it should be the same as in the original.
Copy link to clipboard
Copied
Thanks for your help! 🙂
I'll probably just leave it as is. Not a huge inconvience.
Copy link to clipboard
Copied
The code looks fine. What exactly is not working? Have you check the console window for errors? In fact, you should probably run this code from the console window before using it on a form, to check for errors.
Use the Acrobat JavaScript Reference early and often

