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

Change Subject Line based on Selection of Drop Down List Java Script - Adobe Forms

New Here ,
May 28, 2024 May 28, 2024

Copy link to clipboard

Copied

I am new to writing Java Scripts and trying to write one that will change a subject line based on a selection of a drop down list.

There error I get is I am getting  is:  "SyntaxError: Missing ) after condition 3 at line 4"

Attached is the whole script that I have so far.  

Can someone help?!

TOPICS
JavaScript , PDF forms

Views

390

Translate

Translate

Report

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
1 ACCEPTED SOLUTION
Community Expert ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

LATEST

To be clear, this is the updated "if" statement

 

if ( cToAddr == "Site NOT Ready North: DispatachNewServicesNorth") {

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Votes

Translate

Translate

Report

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 ,
May 28, 2024 May 28, 2024

Copy link to clipboard

Copied

The script is missing quotes around the text in the "if" statement on line #3.

However, the if condition is incorrect. It needs to use the variable that was set to the field value "cToAddr", to compare to the quoted string. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
New Here ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

Thank you so much!  I think I have it working now!

Votes

Translate

Translate

Report

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 ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

In the future please share code only as text, not as an image. It makes it much more difficult to debug it that way.

Votes

Translate

Translate

Report

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
New Here ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

Thank you for that tip.  First time post!  Here was the code 

 

var cToAddr = this.getField("DropdownEmail").valueAsString;

if ("DropdownEmail" == Site NOT Ready North: DispatachNewServicesNorth) {
var cSubLine = this.getField("Service Address_2").valueAsString + " " + "Not Ready";
} else {
var cSubLine = "Trying this out";

}

var cBody = "Notification" + " " + this.getField("Notification#").valueAsString + "-" + this.getField("Service Address_2").value;
this.mailDoc({
bUI:true,
cTo:cToAddr,
cSubject:cSubLine,
cMsg:cBody
});

 

I had changed the the If statement to add extra quotes as suggested as above and appears to be working now!  Appreciate the help!

Votes

Translate

Translate

Report

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 ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

LATEST

To be clear, this is the updated "if" statement

 

if ( cToAddr == "Site NOT Ready North: DispatachNewServicesNorth") {

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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