Tree Picker - prevent the parent options to be selected

Randave Winston
Tera Contributor

Hello! I have this requirement where only options of a tree picker without a child option can be selected. Kindly see the example below:

RandaveWinston_0-1713761587705.png

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!

6 REPLIES 6

@Randave Winston 

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.

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

Ryan Duce
Tera Guru

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,