Skip to main content
Participant
May 28, 2024
Answered

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

  • May 28, 2024
  • 2 replies
  • 893 views

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?!

This topic has been closed for replies.
Correct answer Thom Parker

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

 

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

 

 

2 replies

try67
Community Expert
Community Expert
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.

Participant
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!

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
May 29, 2024

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

 

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

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
May 29, 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
May 29, 2024

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