Expand my Community achievements bar.

Customize body of pdf mailto email with no click events

Avatar

Level 2

I have a preSubmit event attached to a regular (not e-mail) button configured with Control Type = Submit (as PDF to URL=mailto:...) that checks all required fields for completion:

if

(AgencySurveyForm.execValidate()){

do action;

}

else

{

app.alert("There are fields that need to be filled out before submitting.");

//not sure if relayout() needs to be here or not...can't remember why I put it in now!

xfa.layout.relayout();

//turn on field highlighting in case it's off

app.runtimeHighlight

= true;

}

That works fine - exactly as it should. But I would like to customize the subject and body of the email that results from selecting Desktop Email Application in Select Email Client dialog box ("The attached file is the filled-out form. Please open it to review the data.")

I had the xfa.host.messageBox and event.target.submitForm customization all set up for the Click event, but that is no longer available with preSubmit. How do I customize the email if I can't do it through a Click event? I tried putting it after the script above as the last part of preSubmit but it wasn't recognized.

                    Thanks (again!)          ~Carol (LCD ES2 9.0, form target ver 8.0+)

6 Replies

Avatar

Level 10

If you want to get the control on the preSubmit event, remove the" mailto:" statement from the property and put it in the event code.

if(AgencySurveyForm.execValidate()){

     do All Other Actions;

     //Keep this as your last statement after all the conditions are met.

     this.resolveNode("#event").submit.target = "mailto:youremail@yourcompany.com";

}

else{

     ...

}

preSubmit.JPG

Thanks

Srini

Avatar

Level 2

Am still having problems with preSubmit event, so have posted form at https://acrobat.com/#d=JmNBgJX6oP5r1DUl07KybQ hoping someone (Srini?) can help me make the correction(s).

Have experimented with setting SUBMIT [regular] button (on Master Page 1) Object > Field > Control Type between Regular, Execute and Submit, but just can't seem to hit on the right combination.

               Thanks (yet again)!            ~Carol (LCD ES2 9.0, form target ver 8.0+)

Avatar

Level 10

Carol,

     I could not able to open the form you uploaded..

     So I did a small test in my machine and sending you the sample code.

     This way you can get a control on the Subject, Message and Email addresses that you want to send the data to. I chose the Submit As "XML", you ca change it to which ever option you want.

     I placed the code in the preSubmit event of the button.

     //form1.Page1.Button1::preSubmit:form - (JavaScript, client)

     if(AgencySurveyForm.execValidate()){

          //Declared 4 variables to capture the data from the respective form fields.

          var strToAddress, strCCAddress, strSubject, strMessage

          // I created 4 different form fields with the names txtToAddress, txtCCAddress, txtSubject, txtMessage to enter the data.

          strToAddress = txtToAddress.rawValue;

          strCCAddress = txtCCAddress.rawValue;

          strSubject = txtSubject.rawValue;

          strMessage = txtMessage.rawValue;

       this.resolveNode("#event").submit.target = "mailto:"+ strToAddress + "?cc=" + strCCAddress + "&subject=" + strSubject + "&body=" + strMessage;

     }

     else{

          app.alert("There are fields that need to be filled out before submitting.");

          xfa.layout.relayout();

          app.runtimeHighlight = true;

     }

PreSubmit.JPG

Hope this helps.
Thanks
Srini

Avatar

Level 2

Srini - Thank you for the code. I added the four form fields to my form and replaced my preSubmit code with yours (see version #80 below), but still get the same "Submit Cancelled" message.

This might provide a clue: if I don't fill out the one required field (AgencyName), it prompts the user for that, and then the "Submit Cancelled" dialog box pops up. Does that mean it is jumping right to the else condition rather than looking at the if part?

Not sure why you couldn't open my first post (form is just under 2MB), but I have deleted that and re-uploaded both versions. Again, my problem is with the preSubmit script event for the SUBMIT button on MasterPage 1. I am getting the same Submit Cancelled with both versions.

https://acrobat.com/#d=wESpWrzrRxKgkCpyR7Ih1w = original version (#79)

https://acrobat.com/#d=3CUlEDHZxbr58*JmEoAFJw = your code (version #80); four form fields have been added at bottom of form page 1 (in red)

(Not sure if you need it or not, but here is link to my Shared workspace: https://acrobat.com#w=84h41xkQ2YI6iSbE4vCIew )

               Thanks!         ~Carol

Avatar

Level 10

Carol,

     You can send your form to my mail id..

Thanks

Srini

Avatar

Level 10

Carol,

     Sent you the corrected file in a separate email. Let me know if it helps..

Thanks

Srini