Skip to main content
Inspiring
Dec 8, 2020 5:38 PM UTC
Answered

Dynamic Email submission with variable fields button does not click

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.

This topic is closed to new replies. Start a new post to keep the conversation going.
Thom Parker
Thom ParkerCorrect answer
Community Expert
Dec 8, 2020 5:52 PM UTC

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 PDFScriptingUse the Acrobat JavaScript Reference early and often

3 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
Dec 8, 2020 5:52 PM UTC

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.

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Inspiring
Dec 8, 2020 5:58 PM UTC

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

Translate
Bernd Alheit
Community Expert
Community Expert
Dec 8, 2020 5:50 PM UTC

Use

this.mailDoc

Translate