Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You're not applying any value to the "Radio" variable...
Copy link to clipboard
Copied
Also, you should probably change this line:
var theSubject = "TII | " + Dropdown;
To:
var theSubject = "TII | " + Dropdown.valueAsString;
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
Also, you need to put all the values you're comparing it to in double-quotes, like this:
if (Radio == "1") {
Copy link to clipboard
Copied
Your code is quite a mess, to be honest.
You can replace all of the first part of it (except for the first line), with just this:
var Dropdown = "";
var Radio = this.getField("Radio Button 1").valueAsString;
if (Radio!="Off") Dropdown = this.getField("Dropdown"+Radio).valueAsString;