Dynamically create a select box based on user roles / groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks for the idea. I updated the question with additional information. Would the removeOption() still be performant with like 60+ options?
