MultiSelect Hierarchal Checkbox
I have come across a requirement from a client that they would like to have ability to select multiple options / values on a variable in service catalog but did not like the appearance of List Collector. Also they were looking to have a hierarchal view i.e. when a checkbox is clicked it should display child options / values.
I realized that there is currently no variable type in ServiceNow that could satisfy this requirement hence I have created my own and would like to share it with you.
Lets take a scenario to explain the requirement and solution clearly.
Customer Requirement:
Customer is building 'New Employee Hire' service under 'Onboarding Services' in Service Catalog. On the first page of order guide, I have added an option for 'Location Services'.
When this is checked and you proceed to 'Choose Options', user would like to see a tab for capturing location requirement.
Once selection is made user would click on checkout. After request is submitted when user navigates to the 'Location Access' requested item. All the locations selected are visible in the same hierarchal view.
Technical Implementation:
For the purpose of building this I have created a UI Macro, Script Include and Catalog Client Script. Please note that this code may not fully satisfy ServiceNow best practices guidelines and is shared just to give you a starting point for your requirement.
UI Macro:
Created a UI Macro "multiselect_checkboxtree" for the variable that would display list in hierarchal view.
Script Include:
Created Script Include "MultiSelect_CheckboxTreeAjax" which would do the glide query to the table.
Variables
Creates two variables in your catalog item as below:
- Locations Access Required, this will be used to display multiselect hierarchal checkbox.
Type: Macro with Label
Name: locations
Macro: multiselect_checkboxtree
Question: Locations Access Required
ii) Location Values, this will be used to store & retrieve values selected on form.
Type: Single Line Text
Name: location_values
Question: Location Values
Catalog Client Script:
Created Catalog Client Script "onLoad Locations Value" which would manage setting checkbox values.
The solution is packaged into the attached update set, feel free to load and commit this update set on your sandbox first before implementing at client instance.
Please share your views on this solution and any enhancements you make.
Cheers
Syed Atif Faheem
Technical Consultant
Emerging Services, ServiceNow.
https://www.servicenow.com/community/itsm-articles/multiselect-hierarchal-checkbox/ta-p/2306947