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

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

New Here ,
May 28, 2024 May 28, 2024

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

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

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

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

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

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

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

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

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!

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

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