Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Case Script

Avatar

Level 3

Trying to write a case script that would drive a list into a pulldown which is no problem. The issue is that Pulldown box 1 drives the list in Pulldown box 2.

There are 20 choices in Pulldown box 1. 19 of those choices create exactly the same list in Pulldown box 2. Once of the choices in Pulldown box 1 creates a different and unique list in Pulldown box 2. So.....

If Case in pulldown box 1 = Option 1 then

pulldownbox2.Additem("choice 1");

pulldownbox2.addItem("choice 2"):

etc....

If Case in pulldown box1 = Anything other that Option 1 then

pulldownbox2.addItem("different choice 1")

etc

I want to avoid having to create a case of exactly the same list for 19 of the options if that makes sense.

Thanks -pc

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You are very nearly there. You could run with this in the preOpen event of the DropDownField2:

// first clear DropDownField2

this.clearItems();

this.rawValue = null;

if (DropDownField1.rawValue == "Option 1")

{

     // deal with the single case in the if statement    

     this.addItem("Choice 1");

     this.addItem("Choice 2");

     this.addItem("Choice 3");

}

else

{

     // deal with the remaining 19 cases in the else statement

     this.addItem("Choice A");

     this.addItem("Choice B");

     this.addItem("Choice C");

}


The above is JavaScript. It is recommended that script that determines the items should be placed in the preOpen event.

Hope that helps,

Niall

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi,

You are very nearly there. You could run with this in the preOpen event of the DropDownField2:

// first clear DropDownField2

this.clearItems();

this.rawValue = null;

if (DropDownField1.rawValue == "Option 1")

{

     // deal with the single case in the if statement    

     this.addItem("Choice 1");

     this.addItem("Choice 2");

     this.addItem("Choice 3");

}

else

{

     // deal with the remaining 19 cases in the else statement

     this.addItem("Choice A");

     this.addItem("Choice B");

     this.addItem("Choice C");

}


The above is JavaScript. It is recommended that script that determines the items should be placed in the preOpen event.

Hope that helps,

Niall