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

Variables with multiple conditions

Community Beginner ,
Oct 02, 2018 Oct 02, 2018

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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

370

Translate

Translate

Report

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 ,
Oct 02, 2018 Oct 02, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Oct 02, 2018 Oct 02, 2018

Copy link to clipboard

Copied

Also, you should probably change this line:

var theSubject = "TII | " + Dropdown;

To:

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

Votes

Translate

Translate

Report

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 Beginner ,
Oct 02, 2018 Oct 02, 2018

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?

Votes

Translate

Translate

Report

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 ,
Oct 02, 2018 Oct 02, 2018

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;

Votes

Translate

Translate

Report

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 ,
Oct 02, 2018 Oct 02, 2018

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") {

Votes

Translate

Translate

Report

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 ,
Oct 02, 2018 Oct 02, 2018

Copy link to clipboard

Copied

LATEST

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;

Votes

Translate

Translate

Report

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