
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2020 05:27 AM
My requirement:
I have created a role, provisioning_approval.
I have created few users and among them i have assigned this role to 3 of them.
I have a form and there i want to list the approval names(select box).
So do we have a way through client script i can directly fetch users having that role assigned to them.
I tried an onLoad script but not sure how to fetch correct list bcz below is giving me current user name.
if(g_user.hasRole('provisioning_approval')) {
g_form.addOption('app',g_user.getFullName(), g_user.getFullName());
}
- Do we have any way to fetch User list based on role
- Should i go through each user in loop and check their role and add in the drop down list.
Please help and let me know if any other details are required.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2020 05:42 AM
If you want all the users with your specific role no need to write script, you can create a lookup select box instead of select box with following conditions:
replace the sys_id of your role, in reference qualifier.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2020 05:41 AM
Hey Hemant,
try like this:
count=0;
var grUserRoles = new GlideRecord('sys_user_has_role');
grUserRoles.addQuery('role', '282bf1fac6112285017366cb5f867469'); // itil //Enter Your role
grUserRoles.query();
while(grUserRoles.next()) {
count++
gs.print(grUserRoles.getDisplayValue('user'));
}
gs.print(count);
Mark correct and helpful if you find response Worthy!!
Best Regards,
Namrata.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2020 05:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2020 05:59 AM
Thanks @Namrata and @Raghav for quick response 🙂
@Raghav it worked when i was logge din as system admin and showing me the drop down list but when i logged in as normal user it did not work, the drop down list showing empty.
can you please let me know if i am missing anything here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2020 06:31 AM
Hey Hemant,
Its depend of which sys_id of role is you choose. Other user might not have that role check it once.
Hope it helps!!
Regards,
Namrata.