Copy link to clipboard
Copied
Hi, everyone. I have a script in drop down field named "MODEL". It has two options is the list, G2500 and ONYX. Depending the selection, the script changes/sets the items of the list. When I try to select an item from the drop down list G1CDU other than first item, it goes back to the first item. So, I'm not able to select any other item.
this.getField("G1CDU").clearItems();
switch (event.value) {
case "G2500":
this.getField("G1CDU").setItems([
"Item 1",
"Item 2",
"Item 3"]);
break;
case "ONYX":
this.getField("G1CDU").setItems([
"Item 4",
"Item 5",
"Item 6"]);
break;
}
Can you please help me in this regard?
Try using this code as custom validation script of MODEL field:
var seti = this.getField("G1CDU");
if (event.value == "G2500") {
seti.clearItems();
seti.insertItemAt("Item3");
seti.insertItemAt("Item2");
seti.insertItemAt("Item1");
} else if ( event.value == "ONYX"){
seti.clearItems();
seti.insertItemAt("Item6");
seti.insertItemAt("Item5");
seti.insertItemAt("Item4");
}
Copy link to clipboard
Copied
Try using this code as custom validation script of MODEL field:
var seti = this.getField("G1CDU");
if (event.value == "G2500") {
seti.clearItems();
seti.insertItemAt("Item3");
seti.insertItemAt("Item2");
seti.insertItemAt("Item1");
} else if ( event.value == "ONYX"){
seti.clearItems();
seti.insertItemAt("Item6");
seti.insertItemAt("Item5");
seti.insertItemAt("Item4");
}
Copy link to clipboard
Copied
Thank you for your help. I tried the if statement like yours. I have figured it out.
I was using javascript in custom calculation script. Now, I'm using it in custom validation script and it is working fine.
Thank you.