Catalog Item Show/Hide According to Multiple Choice

Sean78
Kilo Contributor

Hello,

So I am making a multiple choice with 3 options (1, 2, 3), and upon selecting these, it will show or hide subsequent single-line variables. My problem is that I can't think of the logic behind a UI Policy or onChange script to allow me to do this. I have tried these Policies:

  • If (number = 1) { 1 is Visible and Mandatory
  • If (number = 2) { 1 & 2 Visible and Mandatory
  • If (number = 3) { 1, 2, 3 Visible and Mandatory

For the life of me I can't figure out how to solve this without ServiceNow screaming at me saying, "You've got duplicate policy actions! Stop that!"

 

Thanks for any input/help provided!

1 ACCEPTED SOLUTION

purbalipc
Tera Expert

you need 3 ui poilcies.

 

1st ui policy-

Condition - if number is 1 or number is 2 or number is 3

action  -1 is visible and mandatory

 

2nd ui policy-

Condition - if number is 2 or number is 3

action  - 2 is visible and mandatory

 

3rd ui policy-

Condition -  number is 3

action  - 3 is visible and mandatory

 

 

Please mark ans as correct or helpful if applicable

View solution in original post

4 REPLIES 4

purbalipc
Tera Expert

you need 3 ui poilcies.

 

1st ui policy-

Condition - if number is 1 or number is 2 or number is 3

action  -1 is visible and mandatory

 

2nd ui policy-

Condition - if number is 2 or number is 3

action  - 2 is visible and mandatory

 

3rd ui policy-

Condition -  number is 3

action  - 3 is visible and mandatory

 

 

Please mark ans as correct or helpful if applicable

Sean78
Kilo Contributor

As soon as I read this, I knew it was the right answer. That makes a lot of sense. Thank you so much!

I had once developed a form with 70 ui policies, so as soon as i read your question I knew that I could answer this query 😄 

Glad I was able to help out.

Rajshekhar Pau1
Kilo Guru

Hi,

UI Policy will always throw you the error: 'There are multiple UI policies on the same field and their run order is not predictable'. In such case, you can change the order of each UI policy to 100,200,300 but that may not work properly on situations.

So, only advice is that, write an onchange client script on number field, and write your script as:

if(newValue == '1'){
//do something
}
else if(newValue == '2'){
//do something
}
else if(newValue == '3'){
//do something
}

Hope this helps.

Mark helpful or correct based on impact