Skip to main content
GeorgeCFray
Known Participant
Oct 2, 2018 4:38 PM UTC
Question

Variables with multiple conditions

  app.execMenuItem("SaveAs");

var Dropdown;

var Radio;

if (Radio == 1) {

    Dropdown = this.getField("Dropdown1");

} else if (Radio == 2) {

     Dropdown = this.getField("Dropdown2");

} else if (Radio == 3) {

     Dropdown = this.getField("Dropdown3");

} else if (Radio == 4) {

     Dropdown = this.getField("Dropdown4");

}

var theSubject = "TII | " + Dropdown;

this.mailDoc({

  bUI: false,

  cTo: this.getField("Text Field 4").value,

  cCc: "george.fray@optimasystems.com",

  cSubject: theSubject,

  cMsg: "Hi, can you please review the attached Engineering Change Request? If you feel that this Engineering Change Request Form can be improved, please contact George Fray"

});

Apologies to say I am back.. my variable code isnt working. I get a result and it is only undefined.

This topic is closed to new replies. Start a new post to keep the conversation going.

6 replies

try67
Community Expert
Community Expert
Oct 2, 2018 4:41 PM UTC

Also, you should probably change this line:

var theSubject = "TII | " + Dropdown;

To:

var theSubject = "TII | " + Dropdown.valueAsString;

Translate
GeorgeCFray
Known Participant
Oct 2, 2018 5:00 PM UTC

  app.execMenuItem("SaveAs");

var Dropdown;

var Radio = this.getField("Radio Button 1");

if (Radio == 1) {

    Dropdown = this.getField("Dropdown1");

} else if (Radio == 2) {

     Dropdown = this.getField("Dropdown2");

} else if (Radio == 3) {

     Dropdown = this.getField("Dropdown3");

} else if (Radio == 4) {

     Dropdown = this.getField("Dropdown4");

}

var theSubject = "TII | " + Dropdown.valueAsString;

this.mailDoc({

  bUI: false,

  cTo: this.getField("Text Field 4").value,

  cCc: "george.fray@optimasystems.com",

  cSubject: theSubject,

  cMsg: "Hi, can you please review the attached Engineering Change Request? If you feel that this Engineering Change Request Form can be improved, please contact George Fray"

});

The email doesnt open when this is completed.

Have i defined Radio correct?

Translate
try67
Community Expert
Community Expert
Oct 2, 2018 5:03 PM UTC

No, you're making the same mistake as with the Dropdown variable. You need to use the value (or valueAsString) property, like this:

var Radio = this.getField("Radio Button 1").valueAsString;

Translate
try67
Community Expert
Community Expert
Oct 2, 2018 4:40 PM UTC

You're not applying any value to the "Radio" variable...

Translate