show/hide choices for list collector variable based on another list collector variable choices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 05:28 AM
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
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 08:29 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 08:39 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 09:46 AM
why not use multi select variable?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 10:02 AM
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