Check for multiple roles from the current logged in user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 07:55 AM
Hi,
I have a requirement to check if the user has 2 specific roles and if he has both the roles then i need to hide and display fields on the form.
How to achieve this using a client script.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 08:10 AM
Check this post https://community.servicenow.com/community?id=community_question&sys_id=275d92aadb1dd3004e1df4621f9619b4
Cheers!!
Anu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 09:38 AM
Hello,
Use this simple onload client script, Tweak code accordingly. Mark my answer as correct if that helps
function onLoad()
{
if(g_user.hasRoleExactly('name of role') && g_user.hasRoleExactly('name of role'))
{
//Show/hide Accordingly
}
}
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2022 06:32 AM
Hello,
If you are fine with my reply, Please mark my reply as correct and close the thread.
Regards
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2022 11:23 AM
Hello,
If you are fine with my reply, Please mark my answer as correct and close the thread.
Regards
Regards,
Musab