Dynamic Dropdown Menu using 'switch' Javascript Not Working

New Here ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

Hello everyone! I have this script at the document level (simplified):

function SetFieldValues(){
var TAMCN = this.getField("TAMCN");
var Model = this.getField("Model");
var Armor = this.getField("Armor");
var Winch = this.getField("Winch");
var Reduce = this.getField("Reduce");
var DFCS = this.getField("DFCS");
var Test1 = this.getField("Test1");
var Test2 = this.getField("Test2");

if(event.willCommit)
{
switch(event.value) {

case "015305676":
	TAMCN.value = "D00037K";
	Model.value = "AMK23";
	Armor.value = "YES";
	Winch.value = "NO";
	Reduce.value = "NO";
	DFCS.value = "NO";
	Test1.setItems[("Not Applicable")];
	Test2.setItems[("-", "Serviceable", "Unserviceable")];
	break;
default:
	TAMCN.value = "";
	Model.value = "";
    Armor.value = "";
    Winch.value = "";
    Reduce.value = "";
    DFCS.value = "";
	break;
  }  
 }
}

This event is kicked off by the Custom Keystroke:

if( event.willCommit )
{
   if(event.value == "-")
     this.resetForm(["TAMCN","Model","Armor","Winch","Reduce","DFCS"]);
   else
     SetFieldValues(event.value)
}

However, my "Test" fields are not populating the setItems.  

I tried this code:

function SetFieldValues(){
var TAMCN = this.getField("TAMCN");
var Model = this.getField("Model");
var Armor = this.getField("Armor");
var Winch = this.getField("Winch");
var Reduce = this.getField("Reduce");
var DFCS = this.getField("DFCS");

const ArmorArray = [field='Test1', field='Test2'];
var ArmorArray;

var CheckOptionsY = {
    Yes: [
        ["-"],
        ["Serviceable"],
        ["Unserviceable"]
    ],
};
var CheckOptionsN = {No: [
        ["Not Applicable"]
    ]  
};

if(event.willCommit)
{
switch(event.value) {

case "015305676":
	TAMCN.value = "D00037K";
	Model.value = "AMK23";
	Armor.value = "YES";
	Winch.value = "NO";
	Reduce.value = "NO";
	DFCS.value = "NO";
	ArmorArray.setItems[(CheckOptionsY)];
	break;

default:
	TAMCN.value = "";
	Model.value = "";
    Armor.value = "";
    Winch.value = "";
    Reduce.value = "";
    DFCS.value = "";
	break;
}}

However, it doesn't set the items list at all on my "Test" dropdowns. 

Any insights are greatly appreciated!

TOPICS
Comment review and collaborate PDF , General troubleshooting , JavaScript

Views

118

Likes

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

correct answers 1 Correct answer

Adobe Community Professional , Apr 26, 2022 Apr 26, 2022

To set Items first use round brackets then squared ones like this:

Test1.setItems(["Not Applicable"]);

 

Likes

Translate

Translate
Adobe Community Professional ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

To set Items first use round brackets then squared ones like this:

Test1.setItems(["Not Applicable"]);

 

Likes

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
New Here ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

LATEST

OMG! ...brackets... It worked perfectly. 

Likes

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