Skip to main content
Participating Frequently
October 24, 2017
Answered

Display data from form in email

  • October 24, 2017
  • 1 reply
  • 1093 views

I have a form created many years ago by someone alot smarter than I.  They used Adobe Acrobat to make a form and added a button that used Java script to email the form to a group.  I have been able to get the script narrowed down to what I need other than I would like for it to add a field from the form, memberid, in the subject line of the email.  Right now the Java code it this:

// submit the form

if (bContinue) {

    var submitURL;

    if (app.viewerVersion < 9.0)

        submitURL = "mailto:djackson@*********.com?subject=Submitting Completed Form <memberid>&body=Instructions to add this form to a response file:\n1. Double-click the attachment.\n2. Acrobat will prompt you to select a response file.&ui=false";

    else

        submitURL = "mailto:djackson@*************.com?subject=Submitting%20Completed%20Form%20<memberid>&body=Instructions%20to%20add%20this%20form%20to%20a%20response%20file:%0A1.%20Double-click%20the%20attachment.%0A2.%20Acrobat%20will%20prompt%20you%20to%20select%20a%20response%20file.&ui=false";

    currentDoc.submitForm({

        cURL: submitURL,

        cSubmitAs: "PDF"

    });

}

All it is doing is putting <memberid> in the subject line, not the actual number from the memberid field in the form.  Any thoughts?  is this even possible?.

This topic has been closed for replies.
Correct answer try67

Sure is. Change the submitURL variable definition to:

submitURL = "mailto:djackson@*********.com?subject=Submitting Completed Form "+this.getField("memberid").valueAsString+"&body=Instructions to add this form to a response file:\n1. Double-click the attachment.\n2. Acrobat will prompt you to select a response file.&ui=false";

I think you have a mistake in it, though. The "&ui=false" part should not be a part of this string, it's a separate parameter.

Also, it won't work. You can't specify this parameter as false, unless the code is located in a doc-level script.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 24, 2017

Sure is. Change the submitURL variable definition to:

submitURL = "mailto:djackson@*********.com?subject=Submitting Completed Form "+this.getField("memberid").valueAsString+"&body=Instructions to add this form to a response file:\n1. Double-click the attachment.\n2. Acrobat will prompt you to select a response file.&ui=false";

I think you have a mistake in it, though. The "&ui=false" part should not be a part of this string, it's a separate parameter.

Also, it won't work. You can't specify this parameter as false, unless the code is located in a doc-level script.

Participating Frequently
October 24, 2017

let me paste the entire thing, I have been going in circles on this for hours.....  Any advice is much appreciated.  Here it is in it's entirety.... PS pretty sure 99% of it is redundant and not needed but I have no clue what I am doing...

//@@SUBMITURL "mailto:djackson@********.com?subject=Submitting%20Completed%20Form%20(member)&body=Instructions%20to%20add%20this%20form%20to%20a%20response%20file:%0A1.%20Double-click%20the%20attachment.%0A2.%20Acrobat%20will%20prompt%20you%20to%20select%20a%20response%20file.&ui=false"

/**************************************************************

AdobePatentID="B643"

**************************************************************/

var AdobePatentID = "AdobePatentID=\"B643\"";

// initiate some constants

var METADATA_ANNOT_NAME     = "adhocFormState";

var PROP_RESPONDENT_NAME    = "respondentName";

var PROP_RESPONDENT_EMAIL   = "respondentEmail";

var currentDoc;

if (typeof(xfa) == "object")

    currentDoc = event.target;

else

    currentDoc = this;

// Only on Viewer/Reader older than 9.0, we'll do the following tasks.

var bAnonymous = true;

var bContinue = true;

if (app.viewerVersion < 9.0) {

    // show the email/name dialog if not anonymous

    if (!bAnonymous && !currentDoc.dynamicXFAForm) {

        var result = currentDoc.askUserIdentity(currentDoc);

        if (result == null)

            bContinue = false;

        else {   

            var annot = currentDoc.getAnnot(0, METADATA_ANNOT_NAME);

            if (annot != null) {

                var arrProps = new Array();

                arrProps = annot.contents.split(";");

                currentDoc.setProperty(arrProps, PROP_RESPONDENT_NAME, result.name);

                currentDoc.setProperty(arrProps, PROP_RESPONDENT_EMAIL, result.email);

                annot.contents = arrProps.join(";");

            }

        }

    }

   

    // show the select client dialog

    if (bContinue) {

        var result = currentDoc.askEmailClient(currentDoc);

        if (result == null)

            bContinue = false;

        else if (!result.send)  {

            app.execMenuItem("SaveAs");

            bContinue = false;

        }

    }

}

// submit the form

if (bContinue) {

    var submitURL;

    if (app.viewerVersion < 9.0)

        submitURL = "mailto:djackson@**********?subject=Submitting Completed Form (memberid)&body=Instructions to add this form to a response file:\n1. Double-click the attachment.\n2. Acrobat will prompt you to select a response file.&ui=false";

    else

        submitURL = "mailto:djackson@**********.com?subject=Submitting%20Completed%20Form%20wtite(memberid)&body=Instructions%20to%20add%20this%20form%20to%20a%20response%20file:%0A1.%20Double-click%20the%20attachment.%0A2.%20Acrobat%20will%20prompt%20you%20to%20select%20a%20response%20file.&ui=false";

    currentDoc.submitForm({

        cURL: submitURL,

        cSubmitAs: "PDF"

    });

}

try67
Community Expert
Community Expert
October 24, 2017

Did you try what I suggested?