Skip to main content
GeorgeCFray
Known Participant
October 2, 2018
Question

Variables with multiple conditions

  • October 2, 2018
  • 2 replies
  • 635 views

  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 has been closed for replies.

2 replies

try67
Community Expert
Community Expert
October 2, 2018

Also, you should probably change this line:

var theSubject = "TII | " + Dropdown;

To:

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

GeorgeCFray
Known Participant
October 2, 2018

  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?

try67
Community Expert
Community Expert
October 2, 2018

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;

try67
Community Expert
Community Expert
October 2, 2018

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