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

Submit a Completed Form using JavaScript

Community Beginner ,
Feb 02, 2024 Feb 02, 2024

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});

 

Capture.PNGexpand image

TOPICS
Create PDFs , How to , JavaScript , PDF , PDF forms
2.1K
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 ,
Feb 02, 2024 Feb 02, 2024

What do you mean? Does it not attach the full PDF to the generated email with this code? It should...

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 ,
Feb 02, 2024 Feb 02, 2024

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). 

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 ,
Feb 02, 2024 Feb 02, 2024

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.

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 ,
Feb 12, 2024 Feb 12, 2024
LATEST

Thanks for your help! 🙂

I'll probably just leave it as is. Not a huge inconvience. 

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 ,
Feb 02, 2024 Feb 02, 2024

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. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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