View Full Version : error in JavaScript on Adobe Acrobat form: emailing

07-07-2011, 11:17 PM
I've not done anything with JavaScript before, so I'm not sure what syntax error I'm committing.

I have a form made in Acrobat 9 for the Mac, and on it there is a "submit via email" button. I want the resulting email, which will contain the filled out Acrobat form as an attachment, to use field from the form to populate the subject line and the CC address field. I've bodgered together some code from this Acrobat user's post (http://acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address), but in trying to customize it, my script has fallen apart.

I think it should be a simple fix, but since I'm so new, I can't see it.

My script so far is:

// This is the form return e-mail. Its hardcoded
// so that the form is always returned to the same address
// Change address on your form
var cToAddr = "fogharty@xxx.xxx";

// First, get the client CC e-mail address
var cCCAddr = this.getField("Teacheremail").value;

// Set the subject and body text for the e-mail message
var cSubLine = "this.getField("CourseNumber").value;
+ "corrections form submitted by " +
+ this.getField("TeacherName").value;
var cBody = "\n Thank you for submitting your form.\n" +
"Save the mail attachment for your own records";

// Send the form data as an PDF attachment on an e-mail
this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr,
cSubject: cSubLine, cMsg: cBody});

So I would like the subject line to read (CourseNumber) corrections form submitted by (TeacherName)

Acrobat tells me I have a "SyntaxError: missing ; before statement
11: at line 12"

but no matter how I tweak it, I keep getting that message. I put the semi-colon in, I take the semi-colon out, I put the semi-colon back in and shake it all about.... nothing.

Any help someone could give me will be greatly appreciated, thanks

Oh, and would there be a way to have the sent pdf form have it's name from a couple of fields as well? So that the attached file will be called "(CourseNumber).pdf"?

07-08-2011, 12:33 AM
Not sure exactly as Im not at my pc so can't see properly or fiddle but...

var cSubLine = "this.getField("CourseNumber").value;

The ; at the end of this line should not be there.

Hope it helps (if only a bit)

07-08-2011, 12:37 AM
You also have a repeated + symbol where the line breaks here:

+ "corrections form submitted by " +
+ this.getField("TeacherName").value;

Again hope it helps if only a little.

07-08-2011, 12:41 AM
And an unexpected " (the first in this chunk of code before this.getField):

var cSubLine = "this.getField("CourseNumber").

Sorry for the bomb of posts. I think I'm done! =)