Expand my Community achievements bar.

Email button presets

Avatar

Level 2

Hello,

I need some help adapting the script below to my form:

https://acrobat.com/#d=Nm2jjpCvBeW9w-T4mXtuWA.

I took a stab at placing the submission script below in the submit button of my form and when it's done and saved and re-opened as a PDF, if you click submit, it does pop up with the javascript window asking you if you want to use your default mail client (in our case outlook) but if i hit ok in that window nothing else happens. The goal is that the person clicks submit and an outlook new message pops up with the filled form attached and the to field pre-populates with my email.

I really like the idea they suggest here, to have the option of saving a "flattened" copy of the filled in form to your computer.

I used LiveCycle ES2

Your help is unimaginably appreciated.

Ioana

Re: Saving Fillable Form as non-fillable PDF

Another very simple (less advance) approach would be to make the ENTIRE form protected, readOnly, nonInteractive, etc. by using the following script:

xfa.form.form1.access = "protected";


In my situation (if this helps anyone), all I wanted to do was enable my user to click an email button to auto-attach a copy of his/her form to an outgoing email, BUT prior to sending the email, I wanted the form to be flattened (i.e. protected). After the email was sent, I wanted it return back to it's open state. So what I did was create a custom email submit button, and added very simple scripts for the preSubmit and postSubmit events. NOTE: This assumes your user is using an email client which will auto-generate an outgoing email (vs. using an Internet email service like GMAIL). If you're using an interent email service, the follwoing scripts will work.

1. Email button: This custom email button script allows me to set the subject, body message, to/cc fields, etc. and email the entire form (wth proper Rights) to a given recipient(s).

Placed on a standard button's click event:


var choice = xfa.host.messageBox("Press OK to submit this form using your default email client (e.g. Microsoft Outlook, Outlook Express, Eudora, Mail, etc.). Note: A copy of this form will be automatically attached to your email. \n\nPress Cancel if you currently use an Internet email service such as Gmail, Hotmail, or Yahoo to send email. You will need save this form on your computer and then manually attach it to an outgoing email (using your Internet email service) addressed to: sample@email.com", " ", 3, 1);

// Note: the above text was taken directly from the typical email submit button text. This gives you a way to modify the text if you want.

if (choice == 1){

var mail;

var address = "email@email.com";

var ccadd = ccAdd.rawValue; //taken from a field placed on the form

var sub = "Subject goes here";

var body = "See attatched file.";

mail = "mailto: " + address + "?cc=" + ccadd + "&subject=" + sub + "&body=" + body;

event.target.submitForm({

cURL: mail,

bEmpty: true,

cSubmitAs: "PDF",

cCharset: "utf-8"

});

}

else{

ProcessManager.terminateAction();

}

2. Script added to same email button (created above) to "Protect" ALL form fields PRIOR to the form being emailed. Place on preSubmit event:

xfa.form.form1.access = "protected";

3. Script added to same email button (created above) to "reopen" ALL form fields AFTER it the form has been submitted. Place on postSubmit event:

xfa.form.form1.access = "open";

From there, the user can save/SaveAs the original file (currently opened on-screen, with active fields), knowing that he's sent a protected copy. Please note that you've sent a "form" with protect fields...it's still a form, vs a truly "flattened copy".  So if security is a major concern, you'd probably want to use a different approach: for example, a digital signature to track from integrity, or print to PDF. Also, this assumes you;re not concerned with tracking "mandatory fields" etc.

As an alternate Step 3, you could interject a SaveAs script on the postSubmit event [app.execMenuItem("SaveAs") ] to allow your user to save a copy of the protected file somewhere on his/her computer after emailing it. Then he/she could simply cancel the current form (on-screen) - without saving it. This assumes you are not concerned with saving an "open field" version with completed data.

Hopes this helps someone!

S

0 Replies