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

Ankur Bawiskar
Tera Patron
Tera Patron

@Randave Winston 

you need to have advanced ref qualifier for this with script include and return the sysIds of record which don't have any child

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

Hello @Ankur Bawiskar,

 

Thanks for your answer. I still need the parent options to be displayed from the tree picker and just want to prevent them from being selected.

@Randave Winston 

what's the point in showing and then running validation?

Why not simply hide those using advanced ref qualifier?

If you want to show and don't want them to select then do this

1) write onChange client script on that field and using GlideAjax verify if this is a parent or child

2) based on that show alert and clear the field

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 

It's to show the which group the child option belongs to. It's like <optiongroup> element in HTML.

 

Yes, I've already done the items you've suggested but we still need to look for ways to prevent the parent option from being selected as this is really our ideal scenario. I appreciate your replies to my post. Thank you very much!