Dynamic Email submission with variable fields button does not click

Explorer ,
Dec 08, 2020 Dec 08, 2020

Copy link to clipboard

Copied

I have submit button on a form that when clicked it sends a PDF attachement to a static mailto, with the cc, subject line, and body all based on a field entry.

 

I based my code on this link:

https://acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address/

 

As a result this is my code.

var cToAddr = "application@email.com";
var cCCAddr = this.getField("Employee_Email").value;
var cSubLine = "Application for" + this.getField("Employee_Name").value;
var cBody = this.getField("Employee_Name").value + "has submitted an Application for review.";
event.target.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody});

 

It appears my code is just wrong. I've tried alternate variations but this seems to be the closest. The Javascript Debugger says:

Acrobat EScript Built-in Functions Version 10.0
Acrobat SOAP 10.0

SyntaxError: missing } after property list
4:
SyntaxError: missing } after property list
4:
SyntaxError: unterminated string literal
7:
SyntaxError: unterminated string literal
7:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
TypeError: event.target.mailDoc is not a function
5:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
5:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
5:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
1:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
1:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
1:Field:Mouse Up

 

Clearly the MouseUp function doesn't like the code, though it's what I want to happen. Click on the button and it submits like this would: 

this.submitForm({cURL: "mailto:application@email.com", cSubmitAs: "PDF"}); 

At this point, I'm at a loss of how to make this function properly.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

53

Likes

translate

Translate

Translate

Report

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

correct answers 1 Correct Answer

Adobe Community Professional , Dec 08, 2020 Dec 08, 2020
That article includes code for both LiveCycle and regular AcroForms. You've copied the LiveCycle (XFA) code.  So first, change      event.target.mailDoc to      this.mailDoc   because "mailDoc" is a document function.    However, you have a lot of other reported errors that do not match the script you've posted. I suspect they are for other scripts on your form. When you are setting up a form it is a really good idea to do one thing at a time, and test it, so you don't have a whole bunch of erro...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Dec 08, 2020 Dec 08, 2020

Copy link to clipboard

Copied

Use

this.mailDoc

Likes

translate

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 08, 2020 Dec 08, 2020

Copy link to clipboard

Copied

That article includes code for both LiveCycle and regular AcroForms. You've copied the LiveCycle (XFA) code. 

So first, change 

    event.target.mailDoc

to 

    this.mailDoc

 

because "mailDoc" is a document function. 

 

However, you have a lot of other reported errors that do not match the script you've posted. I suspect they are for other scripts on your form. When you are setting up a form it is a really good idea to do one thing at a time, and test it, so you don't have a whole bunch of errors walking on top of one another. I would strongly suggest deleting all scripts from the document and rebuilding the form one script at a time.

 

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

Likes

translate

Translate

Translate

Report

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
Explorer ,
Dec 08, 2020 Dec 08, 2020

Copy link to clipboard

Copied

Thank you so much. It works now. I will look at those other scripts. 

Likes

translate

Translate

Translate

Report

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