Tree Picker - prevent the parent options to be selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2024 09:55 PM
Hello! I have this requirement where only options of a tree picker without a child option can be selected. Kindly see the example below:
In this case, only the highlighted options are allowed to be selected. Do you have any ideas on how I can implement this?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 01:04 AM
I can only think of either restrict or let them select and then validate.
hiding the parent using DOM manipulation is not recommended even if it's achievable
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
04-22-2024 01:02 AM
I would consider not using the tree picker at all. Tree pickers are supposed to facilitate picking any item in the hierarchy, and if you're only allowing people to select the leaf node then using the tree picker is likely to mislead users, as well as adding custom script which is challenging to upgrade and results in repeated failures by the user to select a valid option which is probably likely to cause more frustration.
My recommendation is to use the standard reference lookup list. I've attached a screenshot of how you can build a simple reference qualifier (on the location table for example) in a report filter builder (copy and paste the query condition into the reference qualifier query on the dictionary / dictionary override record using SN Utils), that prevents anything but child nodes from being selected. You can then include the Parent column in the autocompleter and the popup view to show a bit of the hierarchy,