Copy link to clipboard
Copied
I'm trying to use the this.submitForm() function to be able to allow users to send the form instead of the built in method due to different emails dependent on user entry of a text field.
Below works—except that I want the pdf to be sent instead of the fdf data. I'm trying to get it to function using the cSubmitAs: input parameter, but can't seem to get the syntax right...
if(manufacturer.value == "Manufacturer A") {
this.submitForm(
"mailto:name@address.com;name2@address.com?&cc=name@address.com;name2@address.com&subject=New Service Request Submittal"
);
}
else {
this.submitForm(
"mailto:name@address.com;name2@address.com?subject=New Service Request Submittal"
);
}
After doing a little research, I've come up with:
var manufacturer = this.getField("manufacturer");
var nEmail = "mailto:name@address.com;name2@address.com?&cc=name@address.com;name2@address.com&subject=New Service Request Submittal";
var allEmail = "mailto:name@address.com;name2@address.com?subject=New Service Request Submittal";if(manufacturer.value == "Manufacturer A") {
this.submitForm({nEmail, cSubmitAs: "PDF"});
}
else {
this.submitForm({allEmail, cSubmitAs: "PDF"});
}
But I seem to be getting JavaScript errors no matter what I try...
When using "{" an "}" in a method indicates you are specifying the parameter name and then the value and not just the positional parameter value. So the "this.submitForm" statements should read:
this.submitForm({cTo: nEmail, cSubmitAs: "PDF"});
and
this.submitForm({cTo:allEmail, cSubmitAs: "PDF"});
Copy link to clipboard
Copied
It seems I just needed to add the parameter "cURL:" before the variable in the array. Then everything's peachy.
var manufacturer = this.getField("manufacturer");
var nEmail = "mailto:name@address.com;name2@address.com?&cc=name@address.com;name2@address.com&subject=New Service Request Submittal";
var allEmail = "mailto:name@address.com;name2@address.com?subject=New Service Request Submittal";
if(manufacturer.value == "Manufacturer A") {
this.submitForm({cURL: nEmail, cSubmitAs: "PDF"});
}
else {
this.submitForm({cURL; allEmail, cSubmitAs: "PDF"});
}
Copy link to clipboard
Copied
That is correct. You do however have a typo in your sample code - you are using ";" instead of ":".
To give you some background: You are passing an object to the Doc.submitForm() function as it's first (and only) parameter. An object in JavaScript uses key/value pairs (the property name and the property value). So by leaving out the key (or property name), you created a corrupt object that did not actually have a valid cURL property.
See here for more information about the Doc.submitForm() method with a description of all parameters: Acrobat DC SDK Documentation
Copy link to clipboard
Copied
Thanks! Yes that's a typo in the sample code. I have it correctly written in the real code.
I've been having an issue on this forum with lag once I tag text with code syntax...
Copy link to clipboard
Copied
I've been having an issue on this forum with lag once I tag text with code syntax...
Welcome to the club When I have more than just a few lines to type, I usually paste my code, type all the text I want to type, and then as a last step select the code segments and use the syntax highlight function.
Copy link to clipboard
Copied
When using "{" an "}" in a method indicates you are specifying the parameter name and then the value and not just the positional parameter value. So the "this.submitForm" statements should read:
this.submitForm({cTo: nEmail, cSubmitAs: "PDF"});
and
this.submitForm({cTo:allEmail, cSubmitAs: "PDF"});
Copy link to clipboard
Copied
Thanks, while I technically found out what I was doing wrong, I wanted to give you the credit instead.
Examples I found before were using "cURL:" while you put "cTo:" could I basically put anything after "c" and have it still work with the first parameter? I was assuming it was the same as the "cSubmitAs" parameter and that it needed to be exactly that to work.
Copy link to clipboard
Copied
No, you need to use the parameter names as specified in the API documentation (see the link I provided earlier). Different methods use different parameters. Doc.submitForm() uses "cURL" as it's parameter name. Doc.mailDoc() or Doc.mailForm() (see here: Acrobat DC SDK Documentation) use "cTo".
Find more inspiration, events, and resources on the new Adobe Community
Explore Now