Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic Email submission with variable fields button does not click

Explorer ,
Dec 08, 2020 Dec 08, 2020

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
1.0K
Translate
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

Community Expert , 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

...
Translate
Community Expert ,
Dec 08, 2020 Dec 08, 2020

Use

this.mailDoc

Translate
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
Community Expert ,
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 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

Translate
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
LATEST

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

Translate
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