show/hide choices for list collector variable based on another list collector variable choices

mohanreshma
Tera Contributor

I have a catalog item having two list collector variables " devices" and "services". For both i'm using reference from sys_choice table and populating data in the form using reference qual as given below as we are using shared instance it's not a gud solution to create custom tables:

 

javascript:'sys_domain=1234565sfghytjukukiloljlo'+'^name=sc_req_item'+'^element= Devices'+'^language=en'+'^ORDERBYDESCsequence';

 

These are the devices

mohanreshma_0-1746447937496.png

 

so now according to the device choice selected the choices in the services field should populate 

choices in the services should be 

1.Email/Teams

2.Access to Network

 

Here are the conditions:

If request is just for Phone, the only option that can be selected in the Services is “Email/Teams/Microsoft”.

If request is for Phone and Laptop and/or Tablet, the user can select one or both options for services.

If request is just for Laptop and/or Tablet user can select one or both options for services.

 

for trying i just added the reference qual field in the variable as shown below:

javascript: var val = current.variables.devices; var query; if(val == 'Laptop' || val == 'Tablet') query = '8f745ce98791e610f358653e8bbb355c,97b64adf3be356107b43014a85e45a2c'; query; (given the sysid of choices from the sys_choice table)

 

How can i write the script for this . Can anyone assist me on how to implement the above? or their is any other possible way to achieve this.

4 REPLIES 4

PraveenkumaM
Tera Contributor

@mohanreshma 

 

Hope you are doing well

 

This requirement should be achievable using 'Select box' for Devices and Services. Create catalog client script to add/remove options under Services based on the onchange value of Devices.

 

Is there any reason you would like to use List collector to pull the values from Choice table?

 

Regards,

Praveen

@PraveenkumaM

 

From both fields i have to select multiple values at a time  that's why i used list collector instead of select box. select box will allow to select only one at a time.

 

Regards,

Reshma

Ankur Bawiskar
Tera Patron
Tera Patron

@mohanreshma 

why not use multi select variable?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

 

I didn't found any such variable named multi select . I tried using Multiple choice variable but it will show as option like radio button . i wanted a field same like select box but it should be able to select multiple values together or sometimes alone as per the customer requirement.

 

Regards,

Reshma