Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

Submitting Form Data by Email

A frequently-asked question is, "how do I modify the email in an email submit button?" Usually, the reason behind the question is that a form should either be routed to a specific person depending on data entered at runtime (so you can’t predict the data and therefore you can’t set the email submit button accordingly at design-time) or perhaps the form even presents a list of possible recipients and the user must choose which person to send the submission data to.

The Secret

The secret to changing the email recipient for an email submit button (or even changing it for a regular button which you’ve turned into a submit button using the "Object palette > Field tab > Control Type > Submit property") is to set the "target" attribute of the <submit> node that is part of the button’s Click event. The "target" specifies the URL to which the data will be submitted. HTTP and mailto are valid protocols.

In XFA, the difference between a regular button with Click event script and a submit button which submits form data when it’s clicked is that the submit button’s Click event has a <submit> node instead of a <script> node.

A regular button’s Click event:

<event activity="click">
    <script contentType="application/x-javascript">
        // your JavaScript code here...

versus a submit button’s Click event (set to email form data in this case because of the "mailto" protocol):

<event activity="click">
    <submit format="xml" textEncoding="UTF-8" target="mailto:"/>

How is it done?

Changing the recipient is done simply by setting the submit button’s target appropriately, following the rules of the protocol you wish to use. In this case, we’ll be using the mailto protocol. Of course, we can do much more than change the recipient: We can actually specify multiple recipients, CC some others, BCC others still, specify any subject we want and even specify a customized email body (message)! All that needs to be done is to apply the mailto protocol when specifying the submit button’s target.

For example, setting the target to the following string would create an email with two recipients (one "to" and one CC’d), a subject and a body: New Account Opening&body=Thank%20you%21"

Note that the body must be URL-encoded using the "%" codes for non-URL characters such as "%20" for a space and "%21" for an exclamation mark (!). Thankfully, we can use the encodeURIComponent(string) method in JavaScript to do that part for us!

The most difficult part of all this is finding the Click event (since there could be multiple <event> nodes specified on a single field, one for each event that does something) and locating the <submit> node inside.

Sample Form

To illustrate how this is done, I’ve created a sample form that submits an address block as data and provides fields for specifying the recipient(s), CC list, BCC list, subject and body of the email.

The result of the above settings is a new email with the specified recipients, subject and body, along with the attached XML data file:


In order to accomplish this, I used the two-button submit technique where a regular button is used to set the properties on a hidden email submit button. Doing it this way also lets me easily prevent the submission if there are no recipients ("to") selected. (Note that the To, CC and BCC fields are multi-select list boxes so you can choose multiple email addresses.) You’ll be interested in the script in the "Send" button’s Click event.

Download Sample [pdf]

Minimum Requirements: Designer 8.0, Acrobat/Reader 8.0 for this form since it uses functions that are part of the new List Object API which was introduced with the 8.0 versions however you could access the selected items differently and get this to work in previous versions as well.

Posted by Stefan Cameron on August 28th, 2008
Filed under Events,Scripting,Tutorials,XFA
Both comments and pings are currently closed.

105 Responses to “Submitting Form Data by Email”

  1. Tammy T on October 20th, 2008

    Thanks so much!!! You finally solved the “send to multiple email addresses” problem for me!

  2. Xancholy on December 12th, 2008

    Stefan, this is just great, thanks.

    I’m having a problem adapting this project.

    I have added 2 buttons “Send” & “EmailSubmitButton”

    I have only 1 dropdownlist with names that go in the TO field.

    I initialize the dropdown as so:

    // add names and email addresses to the “To” dropdown list

    var recipientList = new Array(new Array(“John”, “”), new Array(“Lisa”, “”),
    new Array(“Paul”, “”), new Array(“Steve”, “”), new Array(“Tracy”, “”));


    for (var i = 0; i < recipientList.length; i++)
    DropDownList1.addItem(recipientList[i][0], recipientList[i][1]);

    Then I’m lost, lol.

    How do I recover the name & email id selected in the dropdownlist from the array and then add it to mailto:

    Thanks !
    How do I

  3. Stefan Cameron on December 12th, 2008


    This should be covered in the sample above. Have a look at what happens in the send button’s click event.

  4. Xancholy on December 15th, 2008

    I have studied the code behind your send button. The example shows how to retrieve from a listbox.

    How can I extract email ids data from :
    item selected of Column #2 of a Dropdownlist ?

    I initialize the dropdown as so:

    // add names and email addresses to the “To” dropdown list

    var recipientList = new Array(new Array(”John”, “”), new Array(”Lisa”, “”),
    new Array(”Paul”, “”), new Array(”Steve”, “”), new Array(”Tracy”, “”));


    for (var i = 0; i < recipientList.length; i++)
    DropDownList1.addItem(recipientList[i][0], recipientList[i][1]);

  5. Xancholy on December 15th, 2008

    How do I retrieve a value from dropdownlist’s selected item’s 2nd column ?

    DropdownList1 selected Column 2 rawvalue

    I think I can figure out the rest. Thanks !

  6. Stefan Cameron on December 15th, 2008


    If you’re using the new list object API, then you would use the getSaveItem() method:


    This would retrieve the data value (i.e. “2nd column”) from the 4th item in the drop down list.

  7. Xancholy on December 15th, 2008

    Thank you Stefan, so how would I retrieve ddl.getSaveItem(itemselected) from ddl’s selected item ?

  8. Stefan Cameron on December 15th, 2008


    Check-out the GetEmailList() function in the sample form’s Send button Click event. It does exactly what you want to do… Loops through items in the list and gets the data value for every item that’s selected.

  9. Xancholy on December 15th, 2008

    Thanks Stefan. I finally managed to understand it by changing the TO listbox in your example to a ddl.

    How can I get your example to send the entire pdf instead of the xml ?

  10. Stefan Cameron on December 19th, 2008


    You would have to change the hidden EmailSubmitButton object to a regular Submit button (change it to a Button and it’ll convert it to a button with submit options set to the email you had in the EmailSubmitButton) then set the “Object palette > Submit tab > Submit As property” to “PDF”. Beware, however, that only users with Acrobat Standard or Pro will be able to submit your form after you do this (unless you use LC Reader Extensions to enable submit rights on your PDF).

    (Note also that due to a minor bug, the EmailSubmitButton object will be renamed to “Button1” after you convert it so you’ll have to change the name back to EmailSubmitButton otherwise code in the Send button’s Click event will fail.)

  11. Xancholy on December 22nd, 2008

    Thank you ! That worked perfectly.

  12. Sandeep on January 15th, 2009

    Hello Stefan,

    I have a PDF form, which is reader extended. My requirement is to submit pdf document to a php script with few parameters. such that, depending on the value of firstname field in the document, the php script should create a folder with that user name and save the pdf document.
    I am trying to send parameters from the submit button. I dont know how to right the equivalent java script for the submit event to call the php script and pass the parameters.

    i have a submit button
    Now depending on the first name (first_name.rawValue)
    i have to pass parameters in that submit button.

    Right now i am able to send the pdf document to the php script and can save the file on the server. and also, i am able to hardcode the parameters in the submit button and send them to the php script

    with this my php is creating a folder name abc and a file abc.pdf

    Thank You

  13. Stefan Cameron on January 15th, 2009


    You would simply modify the button Click event’s //submit@target attribute, as I demonstrate in the sample form in this post, to be a URL which you would build dynamically using the rawValue properties of various fields like username…

  14. Malou on January 30th, 2009


    I’d like to ask if I can use this sample pdf you made using Adobe Acrobat 9. I’m also doing the same form to be send in multiple email. I just want to know how will I run the SEND BUTTON using Adobe Acrobat 9 if I choose multiple email address…

    thanks and waiting for your response.

  15. Stefan Cameron on January 30th, 2009


    There’s shouldn’t be any issues running my sample form in Acrobat/Reader 9. In fact, I used Designer 8.2 and Acrobat 9 to build it, though I made it compatible back to Acrobat/Reader 8.

  16. pinal on February 13th, 2009

    pls give me how i sent mail to the provider when provider register in the site?

  17. Taylor on February 19th, 2009

    I’m creating a conference room request form with an Submit by Email button that’s targeted to our receptionist who processes the requests. Is there a way to add a second button our receptionist can click that returns the confirmation information (at the bottom of the form) to the Requestor? I have a text field set up already for the Requestor to fill in their email address.

    Thank you in advance!

  18. Stefan Cameron on February 26th, 2009


    Provided the text field for the requestor’s email address is bound to data (“Object palette > Binding tab > Default Binding property” is not set to “None”), the email address will be displayed in the form when your receptionist opens it.

    At this point, you could use some of the concepts from this post’s tutorial to set the destination email address for a secondary email submit button on the form which your receptionist would use to confirm the request. Basically, in the button’s Initialize event, check for a value in the text field. If there’s no value, disable the button (this.access = ‘readOnly’) or hide it (this.presence = ‘hidden’). Otherwise, use the techniques in the sample form from this tutorial to set the email address on the button’s <submit> Click event node.

  19. Melissa on March 4th, 2009

    I have a form with an Email Submit to Button that I have set up to go to 2 email addresses. When I hit the submit button, the first email address is repeated and the second email address is completely ignored. I tried the above steps and those don’t seem to help. Is there any other way to get the second email address recognized?


  20. James on March 4th, 2009

    I have an email submit button, but I would like a required field to be validated before submission. I can get a “required field” alert to come up, but then it just continues on to submit the form anyway. This is the javascript I’m using:

    var S = this.getField(“Signature”).value;
    if (S ==”Off”)
    app.alert(“You must check the signature box before submitting.”);
    T.readonly = false;
    F.readonly = false;
    var T = this.getField(“DR”);
    var F = this.getField(“FD”);
    T.readonly = true;
    F.readonly = true;

    How can I get this to not allow submission unless the signature box is checked?

  21. Stefan Cameron on March 5th, 2009


    How, exactly, have you setup the email submit button with the two email addresses? What email application are you using?

  22. Markus on March 12th, 2009

    is it possible to program the submit button in a way that it would direct the form to varying sets of emails addresses depending on the choices selected from a drop-down list on the form? And if so, what would the code be like? Would you, or s/one here know?

  23. Dominique on March 12th, 2009

    Would like to know if you can send an email with a submit button without opening a email program. Can it be done by just clicking on the submit button and pdf form is sent directly to recepient?

  24. Stefan Cameron on March 12th, 2009


    I would use a drop down list with items that have text and value data (set using the “Object palette > Field and Binding tabs”). For the text, I would set a friendly name for a list and for the pertaining value, I would set the list of email addresses like “;;”. Then, in the script, when it’s time to set the “to” addresses, I would have the script obtain the value of the drop down list (e.g. “RecipientLists.rawValue”) and use that as the email addresses to set. Have a look at the script in my sample form to see how it works.

  25. Stefan Cameron on March 12th, 2009


    Unfortunately, for security reasons, you cannot circumvent the email program when submitting by email.

  26. Markus on March 13th, 2009

    thank you very much. This was very helpful.
    However, I still keep getting an message ‘error code 4 (invalid token) in reference to the script’s email subject line. What you know what is still wrong with the script:

    if (DropDownList1.rawValue != null){ = “mailto:” + DropDownList1.rawValue? Testing New Form&body=Please%20find%20attached%20the%NewForm%21″;
    } else {
    app.alert(“Please select a choice from the drop-down list! Use the slider to make all 15 choices visible!”);

  27. Melissa on March 13th, 2009

    I have replied three times. Not sure why it doesn’t post. I am using Novell GroupWise.

  28. Stefan Cameron on March 13th, 2009


    For some reason your two previous posts were flagged as spam so I wasn’t seeing them in my moderation list. Sorry about that! Thankfully your third one made it through.

    So you’re using Novell GroupWise as your email client. How have you setup the email submit button to go to two email addresses?

  29. Melissa Chiong on March 16th, 2009

    I just have both addresses listed in the to field separated by a comma. I used an Email Submit button to set it up. That’s all. The form goes to the same 2 people every time.


  30. Stefan Cameron on March 16th, 2009


    It looks to me like you’re missing a few quotes for string concatenation in your statement inside the IF. Perhaps you meant: = “mailto:” + DropDownList1.rawValue + "? Testing New Form&body=Please%20find%20attached%20the%NewForm%21?;
  31. Stefan Cameron on March 16th, 2009


    You would need to use the “two button submit” technique, described here.

    Also note that you shouldn’t be accessing fields using “this.getField()”. This isn’t the proper way to access fields in an XFA form…

    Another option would be to make the signature field mandatory (you may need to set its mandatory property to “error” using an Initialize script since Designer doesn’t give you a property to set this in the Object palette). This should prevent the form from being submitted until the user signs the field. In the signature field’s Initialize event, using the Script Editor palette, set this code:

    // JavaScript:
    this.mandatory = "error";
  32. Melissa on March 17th, 2009

    Here is the code:


  33. Stefan Cameron on March 17th, 2009


    Your code didn’t make it through. Please make sure you replace any < characters with &lt; (HTML character code equivalent). Otherwise, it’ll be interpreted as HTML code and will be filtered-out.

  34. Melissa on March 17th, 2009

    <submit format=”pdf” target=”;” textEncoding=”UTF-8″/<

  35. Stefan Cameron on March 20th, 2009


    That looks OK. Maybe Novel GroupWise wants a comma (,) instead of a semi-colon (;) like the one that’s set in your code. Try separating the email addresses with a comma instead of a semi-colon to see if the second email sticks.

  36. Jim Moyer on April 7th, 2009


    I’m new to LiveCycle, but getting the hang of it. I am not a programmer but have succesfully created a simple request/booking form that e-mails the .pdf to a distribution list. However, we are more interested in extracting (parsing) the text entries for this form and having them make up the body of the e-mail message as opposed to attaching the larger .pdf file. Makes it even more portable as plain text that can easily be cut and pasted into other apps, lighter doc weight, etc.

    From the meager understanding of Javascript and XML that I’ve been able to develop so far, this seems possible without having to engage a CGI/server solution. In other words, I’m hoping that I can write a script within the .pdf’s XML Source itself that will parse this text into the email.

    Is this possible? Don’t break my heart, man. The worst answer is “no” buy I’m hoping you’ll say, “Yes, but you have a lot of programming and learning to do.” My thought was that if I identify all the fields in the document and embed them in the context of the that begins with the command, I can then tell the document to pop all the fields into the body of the e-mail…

    PS – I was really excited to find your blog. Thanks for the support.

  37. Stefan Cameron on April 11th, 2009

    Jim Moyer,

    Sure it’s possible! It’s quite easy, actually. If you were to do this with my sample form from this post, you would simply change how the body of the email is set. Instead of getting the value of the Body field as the body of the email, you would just create a function, say “GetBody()”, that would return a string that would contain the information from the fields in the Data subform (the address block).

    If you replaced the following lines in the Send button’s Click event:

    if (Body.rawValue != null && Body.rawValue.length > 0)
        optionList.push("body=" + encodeURIComponent(Body.rawValue));

    with the following line:

    optionList.push("body=" + encodeURIComponent(GetBody()));

    and you defined the following GetBody() function inside the Click event:

    function GetBody()
        var body = "Customer Address:\n\n";
        body += "Name: " + Data.Name.rawValue + "\n";
        body += "Address: " + Data.Address.rawValue + "\n";
        body += "City: " + Data.City.rawValue + "\n";
        body += "State: " + Data.State.rawValue + "\n";
        body += "ZipCode: " + Data.ZipCode.rawValue + "\n";
        body += "Country: " + Data.Country.rawValue;
        return body;

    The body of the email would look like this (assuming you entered some values into the address block fields in the Data subform):

    Customer Address:
    Name: John Doe
    Address: 123 Main St.
    City: The City
    State: CA
    ZipCode: 12345
    Country: The Country

    Furthermore, if you didn’t want the XML data file submitted to contain the address block data on top of it being in the email’s body, you could simply remove the data bindings on the Data subform and all of the fields that it contains by setting each object’s “Object palette > Binding > Default Binding property” to “None”.

  38. Nancy on April 15th, 2009

    I’m having the same problem as Melissa. I have a form that needs to be submitted to the same three e-mail addresses each time. I’ve tried separating the mailto: command under “submit a form” by commas and semi-colons, both with spaces and without spaces. We use Groupwise as our mail client. The first e-mail addresses is picked up three times and the other two are ignored. Any suggestions?

  39. Stefan Cameron on April 17th, 2009


    Can you temporarily change your default email program to Outlook Express just to see if that makes a difference? I’ve never had this problem before with other email programs so I’m thinking it’s an issue with the way Groupwise deals with the mailto protocol.

  40. Julie on April 22nd, 2009


    I tried downloading the PDF sample and I got an error message. Could you possibly send me a sample?


  41. Stefan Cameron on April 22nd, 2009


    Do you mean you weren’t able to download the PDF? Or were you not able to open it after downloading (in which case, are you using Acrobat/Reader 8.0 or later)?

  42. Tara on June 17th, 2009

    Hi Everyone

    I am still very new to this. My problem is that I was to pre-define the email address dependent on items selected in a dropdown in the form. E.g:

    If “drop down box” == “1”

    Else if “drop down box” == 2

    Else if “drop down box” == “3”

    Is this possible?

    Many thanks

  43. Dale on June 17th, 2009


    Is there a way to change the name of the file before it gets attached to the email? Adobe gives it a garbage name and I was wondering if there was a way to change it to something more appropriate.

    Also, having the same issue as Melissa. My Company also uses Novell Groupwise. I have the user enter their information using response boxes. See below.

    It does not matter if they separate the addresses via “;” or “,” the result is the same. First email is duplicated. I had not thought to test for this until I saw Melissa’s question

    var mail;

    var vAddress = (“Please enter the email address”,”EMAIL RECEIPIENT”,””,0);

    var vSubject = (“Enter subject line”,”WHAT IS EMAIL ABOUT”,”Here is the file you wanted”,0);

    var vBody = (“Enter body of email”,”Details”, “Here is the file you requested. Thanks for your time”,0);

    if (vAddress == 0 || vSubject == 0)
    { (“Email Cancelled”,”This file will not be emailed”,0,0);
    mail = “mailto: ” + vAddress + “?subject=” + vSubject + “&body=” + vBody;{
    cURL: mail,
    bEmpty: true,
    cSubmitAs: “XDP”,
    cCharset: “utf-8”

  44. wert on June 22nd, 2009

    the form i hav created has a submit by email button but the resultant data filled by people is mailed to me in da form of data i want the resultant output in da form of da pdf itself pls help

  45. Stefan Cameron on June 22nd, 2009


    You would need to script the Change event of your drop down list in order to determine the item that the user selected:

    // JavaScript:
    var address = "";
    switch (xfa.event.newText)
        case "1":
            address = "";
        case "2":
            address = "";
        case "3":
            address = ";";
    if (address.length > 0)
        // an address is selected -- modify the submit node as
        //  in the Click event of my sample form (in this post)
  46. Stefan Cameron on June 22nd, 2009


    Unfortunately, there’s no way to change/specify the file name of the attached form or XML data file. The name will always be the name of the form. If your form is in XDP format, previewing it in Designer will result in a temporary PDF version of the form being generated with a garbled name, which explains the weird name when you submit from preview.

    As for the Novell Groupwise problem, I don’t know how to solve it. Perhaps it’s expecting a different separator for email addresses (other than a comma or colon character). You should create a new email and add multiple recipients to see how they’re specified in the box. That might reveal the format it expects to delineate multiple addresses and then you can use that format when you set the <submit> node properties.

  47. debbie on June 24th, 2009

    I tried using ur sample the problem is that after the users fill in da data in da pdf and submit it,i get the output in da form of an xml document.i want da output as a pdf itself

  48. Stefan Cameron on June 26th, 2009


    To email the PDF itself you need to use a regular button, set its “Object palette > Field tab > Control Type property” to “Submit”. Then set its “Object palette > Submit tab > Submit to URL property” to “mailto:email@addresscom” and its “Submit tab > Submit As property” to “PDF”.

    Note, however, that this will only work in Acrobat Standard/Pro since it’s considered equivalent to saving the form and Reader cannot do that unless the PDF form has been enabled for this feature using LiveCycle Reader Extensions ES.

  49. Jay B on July 13th, 2009

    I have an active form (job application) pdf made in lifecycle about a year ago. Its been working fine until suddenly emails with this as an attachement are no longer being received.
    I have checked my email system by testing other pdfs,docs, etc. and its only happening with this specific file. Could this be a symptom of reaching the 500 download limit? Could you suggest anything? I hope there are other remedies besides rebuilding the form from scratch and giving it a new name.
    Please advise.

  50. dan on July 14th, 2009

    i have created a simple form in livecycle (i have no experience programming code). i have thus far figured out how to send an email to a recipient but i want the subject line to reference a field in the form, instead of giving an identical subject line for every email. what is the easiest way to do this. i would probably need some help with the code


  51. Stefan Cameron on July 17th, 2009

    Jay B,

    I doubt you’re being hindered by the “500 limit”. As long as the extended version of the PDF form is being used to fill and submit from within Reader, the PDF should be submitted (though if you’ve surpassed the “500 limit” for this form, you may be in violation of your Acrobat license agreement). Is there an older version of the form out there that’s submitting to an old email address (which might explain why you aren’t receiving some of the submissions)?

  52. Stefan Cameron on July 17th, 2009


    Check-out my tutorial on submitting form data by email. That will show you how to change the subject to whatever you like.

  53. Edwin Woolf on October 13th, 2009

    Hi Stefan, I am an advanced Designer developer and really appreciate your presence! I have the need to get form XML in an exact format that matches a schema. I used javascript on the click event of the submit button to write the form data into a hidden text field which had the required schema format. Sadly this approach is only partially successful because the final XML submitted still contains surrounding tags ,and lt and gt are converted to their html entities. I have suggested to management that we either need to use a webservice or post-process the xml after it’s received at the server (not a difficult task), but this is a last resort since it has other impacts on our current system, so first prize is getting the xml in the exact format needed at the form end.

    Do you perhaps have any ideas on how I can exactly control the XML that is submitted?

    Tx very much,


  54. Stefan Cameron on October 19th, 2009

    Edwin Woolf,

    Creating a Schema Data Connection will let you control the structure of XML data imported into and exported from your form.

    Once that connection is created, you can also specify XSLT templates to further transform imported and exported data, if required.

  55. Project Manager on November 11th, 2009


    In post 37 above on April 11th, 2009, to Jim Moyer, what you show is exactly what I need to do with a form. Unfortunately, I’m not so savvy on the scripting, and couldn’t figure out where to place the GetBody function.

    Is it possible for you to modify your sample PDF so it does this? I could probably take it from there, modifying it to fit my form fields.

    Thank you!

  56. Stefan Cameron on November 19th, 2009

    Project Manager,

    Just put it in the Send Button’s Click event, above the code that’s already there, and make sure you call it where I say to do so in comment 37.

  57. Soek on January 5th, 2010

    Hi, i try to make a (PDF) form (in LC Designer) with a “e-mail” button in it.
    If i click on the “e-mail” button, the pdf file (after filling the open fields) must be sent as a PDF to the recipient.
    But when i click the emailbutton, the recipient gets a XML file and this is what the recipent see ”

    The Question is now, how can i make it possible for the recipient to have receive a PDF and NOT an XML.

  58. Stefan Cameron on January 5th, 2010


    Unfortunately, you must either submit from Acrobat Standard/Pro or use LiveCycle Reader Extensions to enable the PDF submission from Reader. Reader alone cannot submit PDFs because it would be the same as allowing you to save a new PDF version of your form (and Reader is not allowed to create PDFs unless permitted to do so by an extension).

  59. Neha on January 6th, 2010

    Hi Stefan…thanks for ur immediate reply…
    i have placed the button (set its properties as Submit) and as my requirement is to send PDF so i set the submit as property to ‘PDF’.
    Now the case is i have one changeable field on pdf which will have email address coming from my interface or user can enter his own email address as well, so the requirement is to send the PDF to all those email addresses entered by the user in that changeable field, so in this case wat wud be my URL string ? and also for this submit button ‘click’ event is coming disabled at my end…Please advise


  60. Stefan Cameron on January 6th, 2010


    The script in my sample form shows how to assemble the URL for multiple addresses.

    As for not being able to set the Click event script on the submit button, note that you need to use two buttons: one regular which you script the Click event and another, the actual submit button, which you programmatically click from the other button. I call this the two-button submit technique (and my sample form use it).

  61. Neha on January 7th, 2010

    Hi Stefan

    i have used two buttons ‘regular’ and other ‘submit’
    behind regular i have applied the code at click event
    EmailAddress is my textfield for email addresses which would accept only commas in between email addresses

    Please suggest if any other thing required as when i click on send button nothing happens.


  62. Neha on January 7th, 2010

    i am not able to send you the scripting i have used…i dont knw why..i want you to check if any other scripting required…
    on click event
    var email = emailaddress.rawvalue
    var target with mailto and email and subject
    at before
    i have passed all the values of with target.
    submitnode.format with PDF
    submitnode.textEncoding with UTF8

    and then at after

  63. Stefan Cameron on January 12th, 2010


    In principal, it sounds right but it would really help to see your script. You should be able to copy and paste it from the Script Editor into the comment box. Just make sure you replace the ‘<‘ characters with the letters ‘&lt;’ otherwise the script will not display properly.

  64. Neha on January 18th, 2010

    I am still not able to send you the script 🙁
    anyways is there any way to call the SAP Function module in adobe form through java code or by any other way?

    Neha Kundra

  65. Stefan Cameron on January 19th, 2010


    I’m afraid I don’t know the answer to your question about the SAP Function Module.

  66. Neha on January 20th, 2010


    what i am doing is now
    i took one list box which has only single value and initialize its value in initailize event
    and used two-button submit and behind send i do exactly same as in your form but when i execute it i didn’t see anything in the list box even after initializing it until i select the default value in ‘Object’ list. i dont want to set the default value and also while pdf preview email popup comes but when execute it nothing happens on clicking the send button…please help…its urgent..
    i dont knw why ur scripting is not working @ my end?


  67. Neha on January 20th, 2010

    Hi Stefan

    Ignore the previous post. Its workinf fine now for my form too..thanks…but only problem is now that attachment is attached in xml but i want pdf
    By the way i am using the following code to send as PDF but it is not working

    console.println(“before: ” + + submitNode.format); = newTarget;
    submitNode.format = “PDF”; = “1”;
    console.println(“after: ” + + submitNode.format);

    Please provide the solution.

  68. Neha on January 20th, 2010

    also to pass subject i am trying to use the below code but its not working

    var newTarget = “mailto:” + toList&;

  69. Stefan Cameron on January 29th, 2010


    Have you tried configuring the submit button using the Object palette? It should give you all the options that relate to submitting the form as a PDF rather than setting them via script (unless you need to do it this way for some reason).

    Do note, however, that only Acrobat can submit the form as a PDF unless you have applied a specific extension (using LiveCycle Reader Extensions) to the PDF form itself in order to submit in PDF format from Reader.

  70. Todd on February 16th, 2010

    Hello Stefan,

    Keep up the good work,
    I like the PDF example, I tried modifying your script a little so I can just use the Subject line from this form and had no luck, can you please help.

    Also this is a little different question, but when I open a form I have been working on in LiveCycle sometimes in the Script Editor the click option is not accessible after I have already put a script in there. Any thoughts?

    Thank You,

  71. Stefan Cameron on February 23rd, 2010


    To use just the subject, you would ultimately set the submit target to something like New Account Opening

    only rather than everything else. Note that you still have to have an email address in there as the primary recipient.

    As for the Click event suddenly not being accessible on an object, I’m not sure why that would happen. Are you certain you’re still looking at the object which had the Click event (i.e. is the right object still selected in the Hierarchy palette or on the canvas)?

  72. Cathy on March 17th, 2010

    I’m unable download your sample form due to firewall restrictions and am having trouble with a couple of things. Am using a button with regular control type and am hoping for 3 things:

    1. Set Date in subject showing as 4 year digit only based on current date
    2. Add the company name to subject
    3. Check for incomplete required fields

    I am not quite clear on using a ‘fake’ submit button which calls a real submit button. Regarding validation, I found below code and the instructions say form1 is the root node, but where do I find the root node. The LiveCycle help menu says in Data View palette, select appropriate node and drag to the field on the page, but my Data View is empty, and I’m sure I don’t know how to find it.

    Would appreciate any help, thank you.

    Here is my JavaScript, of which I am brand new to, and don’t know if things are the right order:

    topmostSubform.Page9.Button2::click – (JavaScript, client)
    //Create a variable to hold the document object
    var oDoc =;

    bUI: true,
    cTo: “”,
    cSubject: + var theYear = submitDate.substring(0,4); + “Contract Form for ” + Company_Name.rawValue,
    cMsg: “Our completed form is attached, per your request.”





    else {

    app.alert(“Some required answers are missing …”);


  73. Ralph on March 19th, 2010

    Hey Stef, you’re previous posts were incredibly helpful when I was creating some forms.

    However, I am trying to have an Send Email button in my latest PDF form. This button will send the form as a PDF attachment. It works however, occasionally, Outlook 2007 will complain and display an error “Cannot send this item.” Have you encountered this error before?

    When I close the email window and click the Send PDF button again, I can send the email. I have no idea why it’s doing that.

  74. Michelle Hutchison on March 19th, 2010

    Hi Stefan,

    Is there a way to email a form to a group of people a so that each individual form is autofilled with specific information and sent to the appropriate email address?


  75. vincent on March 20th, 2010

    Is there a way to rename PDF that’s attached to the email depending on the user input on the form?

  76. Stefan Cameron on March 20th, 2010


    Unfortunately, the name of the attached PDF or XML data file is based on the file name of the form being submitted and cannot be customized.

  77. Stefan Cameron on March 21st, 2010


    The root subform is the top-most subform in the Hierarchy palette, not the Data View palette.

    Is it possible for you to download my sample form from another computer that doesn’t have the firewall restrictions? It really does show everything you would need. I can email it to you if you give me an email address to send it to. If you don’t want to share it here, you can email formcollateral1 [at] and I’ll send it as a reply.

    The JavaScript you included is very AcroForm-centric (JavaScript in Acrobat Forms). This sample deals with JavaScript in XFA-PDF Forms.

    As for having one button call another, I explain how that’s done in this tutorial.

  78. Jerry W. Mcleod on March 22nd, 2010

    Hello there Stefan.

    Need a good (how-to-for dummies) tutorial on dynamic forms. Just purchased LiveCycle, and I love the way the sample files let you input extra rows when needed for purchase orders or reference form. I would really love to know how to do this from scratch. Looked at some books, but I need step-by-step how-to instructions. Can you offer or suggest any real good sources.

    By the way, I cant wait till the eSeminar tommorow. I know its going to be very complicated, but I am definitely interested in it. May converse with you by chat then.

    Jerry Mcleod

  79. Stefan Cameron on March 22nd, 2010

    @Jerry W. Mcleod,

    I think I might have just the thing for you: Check-out my tutorial for MAX 2007. The topic was creating a dynamic form from scratch. There are multiple exercises and class notes to follow along.

    If that tutorial isn’t what you’re looking for, you could always have a look at this book by J.P. Terry on creating dynamic XFA forms, as well as the PDF Forms Bible by Angie Okamoto and Ted Padova which covers everything from using Designer to creating data-driven dynamic XFA forms.

    The eSeminar should be very informative. I’m looking forward to it as well!

  80. Ken on March 23rd, 2010

    Hi Stefan,

    Please could you help with a query I have regarding data export from acrobat 9 pro to excel from a form designed in livecycle? I’ve searched all over the web and adobe but cant seem to find anything specific related to my issue. I’m also new to the software so am struggling a bit.

    Staff will complete a form they download from the web and return it to me via email. I then want to export that data into excel but when i do this the names of the fields/questions in the form like ‘name’, ‘gender’ do not come out in the column headers in excel. Instead they appear like this – form1[0].TextField1[0]. They are also not in the order I want them. Is there a way to fix this?

    Any help greatly appreciated,



  81. Stefan Cameron on March 25th, 2010


    I’m glad to hear you found my posts helpful!

    Unfortunately, I’ve never seen that email error occur before. If you can figure-out a consistent way to make the error happen, that might be something to go on.

  82. Stefan Cameron on March 25th, 2010

    @Michelle Hutchison,

    Unfortunately not in an automated (i.e. non-interactive) way. What you would need is a LiveCycle process, running in a LiveCycle server, to run through 10 different sets of data, merging them into a PDF and emailing the result, one by one, using the right email address.

    That being said, there may be a way to do this using trusted scripts in Acrobat but I don’t know how to do that.

  83. Stefan Cameron on March 25th, 2010


    Unfortunately, it looks like that’s just the way in which the data is exported.

    Assuming you’re getting an XML data file back and you’re attempting to use Acrobat 9’s “Forms > Manage Form Data > Merge Data Files into Spreadsheet” feature, you could try doing it the other way around: Import the XML data file into an Excel spreadsheet using Excel 2007’s “Data > From Other Sources > From XML Data Import”. In my case, this gave me just the data in separate columns; there may be a way to generate column headers as well, I’m not sure.

  84. Ken on March 26th, 2010

    Thanks Stefan. You’re right I was doing it via “Forms > Manage Form Data > Merge Data Files into Spreadsheet”, I should have said. I want it all exported to excel so I can do further work with all the data. I only have Excel 2003, so I’m not sure if this will still work, I’ll try. What’s an XML data file?

  85. Stefan Cameron on April 3rd, 2010


    An “XML data file” is the type of file format used by default when submitting a form from Reader. By default, Reader can only submit XML or URL-encoded data.

    Excel can interpret an XML file as a record (so each form submission would constitute a record). It can also infer an XML Schema (a description of an XML file’s structure) based on an arbitrary XML file.

  86. Richard on April 5th, 2010

    Please help. I urgently need a quick and dirty form where the user can input: a “unitId”, “emplName”, “jobTitle”, and “probDesc”. The “TO” and “SUBJECT” fields will have static values. The content of the email body should appear as follows (I used .value to indicate vars that will be de-referenced)

    I hope the formatting isn’t mangled when posted.


    %AFFECTED END USER= unitId.value
    Employee: emplName.value
    Job Title: jobTitle.value

    Here’s the code.

    —– form1.#subform[0].Email.Send::click: – (JavaScript, client) —

    function GetBody()
    { var body = “Message Body: ” + “\n”;
    body += “Employee Name: ” + emplName.Value + “\n”;
    body += “%AFFECTED END USER= ” + UnitId.Value + “\n”;
    body += “%CATEGORY= ” + category.value + “\n”;
    body += “%GROUP= ” + group.value + “\n”;
    body += “%DESCRIPTION= ” + probDesc.value + “\n”;
    return body;

    body = GetBody( );

    var newTarget = “mailto:” + to.value + “?” + “body=” + encodeURIComponent(GetBody()); = newTarget;

  87. Richard on April 6th, 2010

    addendum: The code above is based on your sample “SubmitByEmail.pdf” I left the two buttons on the form and deleted all code. I then added what you see above. Before I changed the way I de-referenced vars the GetBody function ran.

    I’m now getting “not defined” errors on refs to vars?



  88. Ralph on April 11th, 2010

    Hey Stef!

    The “Cannot send Item” error that I keep getting in Outlook 2007 seems to be a bug within Outlook 2007. I found that after creating the new email message, I must send the email immediately. If I wait (about 5 seconds), then once I click the “Send” button, I get the “Cannot send item” error. It’s incredibly odd. Oh well.

  89. Stefan Cameron on April 14th, 2010


    I believe your code isn’t running because you’re attempting to get the value of fields by accessing an undefined “value” property. You should use “rawValue” instead.

  90. Michelle Hutchison on April 16th, 2010

    Hi Stephan,

    Thanks for your previous response. I have another question about saving pdf files. I have a form that will be completed from a phone call numerous times throughout the day and it contains a date and time field. Is there anyway to set it up so that the date and time are selected automatically for the file name so that the user doesn’t have to create a file name? The date and time would come from what is filled in on the form.


  91. Stefan Cameron on April 25th, 2010

    @Michelle Hutchison,

    I believe you’re asking if you can suggest a file name when the user submits their form via Email.

    If so, then I’m afraid the answer is “no”. The file name of the attached data file (XML, XDP, or PDF) will always be identical to the name of the form whose data you are submitting. The best you can do is programmatically set the email’s subject or body to contain the desired date.

  92. scott on June 17th, 2010

    I am in the same position as Jim Moyer in post 36 – I have followed your answer in post 37, but where exactly do you find the “send button click event”?
    Is it found in the “xml source” in LiveCycle?
    Or is it found in the “design view”?
    Sorry for the rudimentary question, but I am a very new user.
    Thanks in advance.

  93. Stefan Cameron on June 29th, 2010


    When editing events on form objects, you need to use the Script Editor palette which is activated by choosing “Window menu > Script Editor”, then selecting an object whose events you want to edit.

    Once you have displayed the Script Editor and selected the Send button, choose the “Click” item from the Script Editor’s “Show” property.

  94. Steve on August 20th, 2010

    Hi Stefan,

    I have a pdf form with a dropdownlist made from LC Designer ES. I’d like to send the completed form in pdf format to different email address based on different item selected from the dropdownlist. The users only have Acrobat Reader.

    I read post #45 and put the script for the Change event of the dropdownlist, and I modified the script for send button’s click event. However, I just can’t make it work. Could you please show how this can be done or provide an example?

    I don’t quite understand why you use two-button technique. Is there anyway that we just use the EmailSubmitButton and determine the button’s “Email Address” field based on retrieved text from the dropdownlist selection?


  95. Steve on August 24th, 2010

    Problem regarding post #94 has been solved.


  96. Stefan Cameron on August 24th, 2010


    Wonderful! Thanks for letting me know.

  97. Emma on August 26th, 2010

    I’ve used your script for this in combination with a radio button to dertemine the email address and everything works great except that childNode.submit is null and I can’t figure out why.

    Could you please give me some suggestions on what and/or where to check?


  98. Emma on August 30th, 2010

    Here is the code I used. I wasn’t sure what the console.println statements were for so I added them but that also did not work and now the code no longer catches the empty radio button field for the Department.

    F.P1.Button1::click – (JavaScript, client)

    function FindSubmitNode(buttonField)
    if(buttonField == null)
    return null;

    var childList = buttonField.nodes;
    for(var i = 0; i < childList.length; i++)
    var childNode = childList.item(i);
    if(childNode.classname == "event" && childNode.activity == "click")
    //found click event — look for the child node
    if(childNode.submit != null)
    return childNode.submit;
    return null;

    if (F.P1.Department.rawValue == null)
    {“Please select your Department”);
    var submitNode = FindSubmitNode(EmailSubmitButton1);

    if (F.P1.Department.rawValue == “FCD”)
    var newTarget = “ Reprographics Request”;
    var newTarget = “ Reprographics Request”;

    console.println(“before: ” +;

    //set the email submit button’s new target information = newTarget;

    console.println(“after: ” +;

    //execute the email submit button with the new target informaiton
    else“Unable to configure email submit button!”);

  99. Stefan Cameron on September 10th, 2010


    Is it possible that EmailSubmitButton1 is not really a submit button? Have a look at it in the XML Source view: Can you see a <submit …/> node in the button’s XML definition? Without this node, the script will fail (childNode.submit will always be null).

  100. Jason on October 13th, 2010

    Hi Stefan,

    I’m only new the Livecycle world and I put this up in another forum without realising each forum addresses different issues (apologies for that).

    I’m having trouble with dynamic fields not being included in the PDF file that is saved or added to an email.

    There is an option to save, print and/or submit by email (as a PDF) the completed form, via the use of three buttons. Each button uses JS code to first set all fields except the other buttons to “readonly” before executing the specific action. The print button works fine, but using the save or submit buttons results in the dynamic fields disappearing from the file that is saved or added to an email.

    I’m using “app.execMenuItem(“SaveAs”)” in the mouseup function of the save button, and “{cURL: cEmailURL, cSubmitAs:”PDF”, cCharSet:”utf-8?});” for the submit button.

    The form properties are set to Dynamc XML, not static PDF.

    Any suggestions as to what I’m doing wrong?


  101. Kevin Hughes on October 18th, 2010

    Hi Stefan,

    Firstly, I have limited experience with pdf forms and even less with JavaScript etc, so apologies for this non-tech question.

    I was very impressed when I saw your sample document “Submitting Form Data by Email” and, with your permission, I would like to use it in the form I’m currently developing? However, in my form I only want to select names from the “To” list and remove both the “CC” and “BCC” fields. Therefore, would it be possible you could send me a revised pdf just with the “To” list without the rest.

    Thanks in anticipation of your reply.


  102. Stefan Cameron on October 18th, 2010


    Please see my response to your question here (commend #148).

  103. Bibhu on October 22nd, 2010

    Hello Stefan ,

    Nice form indeed. But I want to design a button which will submit both the XML as well as the PDF to the email specified.Is it possible in LiveCycle Designer 8.2 ?



  104. Stefan Cameron on October 23rd, 2010

    @Kevin Hughes,

    You are free to re-use my sample form (or code within it) for your form.

    I can’t, however, provide you with an updated sample that doesn’t have the CC and BCC fields in it. Removing them is simple using Designer:

    1. Load my sample form in LiveCycle Designer.
    2. Select the two fields and delete them.
    3. Select the “Submit” button and look at the Click event script in the Script Editor (you can show the Script Editor via the “Window menu > Script Editor command”).
    4. Remove all references to the CC and BCC fields in the script.

  105. Stefan Cameron on October 23rd, 2010


    As far as I know, you can only submit the form in one format per submit operation.