Dynamically create a select box based on user roles / groups

Leon Tutte
Giga Guru

Hello everyone,

 

today I got an interesting question. A customer wants to have a dropdown where a user can only select items based on the user's groups or roles. I had the idea of writing the options into a table with a list field that holds the applicable user groups. Then I would potentially use a client script to check the items before displaying them in the select box. 

 

For further clarification, we are talking about 60+ options, each tied to one or more groups or roles. Also the customer wants to exit the roles applicable via a request in the future.

 

It's just an idea. Has anyone done something like that?

3 REPLIES 3

Ankur Bawiskar
Tera Patron

@Leon Tutte 

you list down the choices in Select box and then use onLoad client script to hide the options based on logged in user role or group membership

you can use g_form.removeOption(), g_form.addOption() methods

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Leon Tutte 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Thanks for the idea. I updated the question with additional information. Would the removeOption() still be performant with like 60+ options?