Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Conditional Display of Choices in ServiceNow Catalog Item Variables

Nikhitha Mohan
Tera Contributor

Hi,

I have created two multiple-choice variables in a catalog item:

  1. Laptop/Desktop (laptop/desktop) with two choices: Laptop and Desktop.
  2. Mode of Laptop Delivery (mode_of_laptop_delivery) with two choices: Shipping the Laptop and Picking it up from the Office Location.

The requirement is as follows:

  • If the user selects Laptop in the laptop/desktop field, both options in mode_of_laptop_delivery should be displayed.
  • If the user selects Desktop, only Picking it up from the Office Location should be displayed, and the other option should be hidden.

I tried implementing this with the following script, but it’s not working. Could you please assist me?

NikhithaMohan_0-1733383722633.png

 

below the variable added,
 

NikhithaMohan_0-1733383531691.png

 

 

6 REPLIES 6

@Community Alums Sure....I wil try

 

shivatmika_19
Tera Guru

Hi @Nikhitha Mohan

Using Multiple choice -> clearOptions() method doesn't work, try using Select box as variables, clearOptions() method will clear all the choices of the field. So, use addOption() and removeOption() instead