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

Assistance Required - JavaScript Syntax Error: missing }

Community Beginner ,
Jun 11, 2024 Jun 11, 2024

I have wititen this script however, I am getting the following Sytax error: missing } after property list 4 at line 5

 

see the script below:

{app.alert("Before sending to PC for review, admins please review the following, -Travel Application Details -Cost Breakdown -Private Travel Plan",3)
var cAlert=app.alert("are we ready to send to PC for review?",3,2)}
this.mailDoc({cTo: this.getField("Email Address"), cCc: "manager@email.com",
cSubject: "Travel Application+this.getField("FullName TravellersRow1").valueAsString+this.getField("City 2").valueAsString+this.getField("Departure Date").valueAsString",
cMsg: Please see the attached for your review and complete the 'Travel Justification'section. Refer to the form with a yellow box labeled ' Send to Admin', click the box and this will auto-generate an email back to the admin. admin will then process the rest of your application and progress to the Manager and Assistant Executive Director for review, sign-off, and approval."});}

TOPICS
JavaScript , PDF forms
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
3 ACCEPTED SOLUTIONS
Community Expert ,
Jun 11, 2024 Jun 11, 2024

There are several syntax errors, I have also added new line for first alert for easier review and condition to second alert to send mail only if answer to alert is "Yes" (let me know if that works for you):

app.alert("Before sending to PC for review, admins please review the following:\n- Travel Application Details\n- Cost Breakdown\n- Private Travel Plan", 3);

var cAlert = app.alert("Are we ready to send to PC for review?", 3, 2);

if (cAlert == 4) {
 this.mailDoc({
  cTo: this.getField("Email Address").valueAsString,
  cCc: "manager@email.com",
  cSubject: "Travel Application " + this.getField("FullName TravellersRow1").valueAsString + " " + this.getField("City 2").valueAsString + " " + this.getField("Departure Date").valueAsString,
  cMsg: "Please see the attached for your review and complete the 'Travel Justification' section. Refer to the form with a yellow box labeled 'Send to Admin', click the box and this will auto-generate an email back to the admin. Admin will then process the rest of your application and progress to the Manager and Assistant Executive Director for review, sign-off, and approval."});}

View solution in original post

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 Beginner ,
Jun 12, 2024 Jun 12, 2024

Afternoon, 

I use 

cTo: this.getField("Email Address").valueAsString,

View solution in original post

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 ,
Jun 12, 2024 Jun 12, 2024

This should work.

View solution in original post

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 ,
Jun 11, 2024 Jun 11, 2024

There are several syntax errors, I have also added new line for first alert for easier review and condition to second alert to send mail only if answer to alert is "Yes" (let me know if that works for you):

app.alert("Before sending to PC for review, admins please review the following:\n- Travel Application Details\n- Cost Breakdown\n- Private Travel Plan", 3);

var cAlert = app.alert("Are we ready to send to PC for review?", 3, 2);

if (cAlert == 4) {
 this.mailDoc({
  cTo: this.getField("Email Address").valueAsString,
  cCc: "manager@email.com",
  cSubject: "Travel Application " + this.getField("FullName TravellersRow1").valueAsString + " " + this.getField("City 2").valueAsString + " " + this.getField("Departure Date").valueAsString,
  cMsg: "Please see the attached for your review and complete the 'Travel Justification' section. Refer to the form with a yellow box labeled 'Send to Admin', click the box and this will auto-generate an email back to the admin. Admin will then process the rest of your application and progress to the Manager and Assistant Executive Director for review, sign-off, and approval."});}
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 Beginner ,
Jun 11, 2024 Jun 11, 2024

Thank you Nesa, appreciate this. will update my script and will respond back shortly.

 

Malo

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 Beginner ,
Jun 12, 2024 Jun 12, 2024

Hello Nesa, thank you so much! this worked wonders!.

 

I have one question, I have highlighted this in yellow for you, in the form I have created a text field so the users can enter their email addresses into them. however this does populate the email address I tested (see the other attachment for the error) and actually stops the email from being generated the minute I removed this field it and made it" ", it works fine, however the 'To' Field is just blank and the 'Cc' field works., is it becuase I need to format this field to generate email?

Manumalo343929158btb_0-1718176001682.png

Manumalo343929158btb_1-1718176314514.png

 

 

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 ,
Jun 12, 2024 Jun 12, 2024

Do you use:
cTo: this.getField("Email Address").valueAsString,
or:
cTo: this.getField("Email Address"),

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 Beginner ,
Jun 12, 2024 Jun 12, 2024

Afternoon, 

I use 

cTo: this.getField("Email Address").valueAsString,

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 ,
Jun 12, 2024 Jun 12, 2024

This should work.

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 Beginner ,
Jun 12, 2024 Jun 12, 2024

the Emaill Address field I have used in the form is a text field is that the correct field to use to enter email addresses into or does the test field need to be formatted using script?

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 Beginner ,
Jun 12, 2024 Jun 12, 2024
LATEST

Thank you Nesa and Bernd, both your assistance has helped, I went back and review my script and decided to save and exit. upon doing so it somehow refreshed what I have inputted in there and has since worked. I will now continue and complete this form. again your help has been much appreciated.

 

Malo

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