- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2023 12:26 AM
Hi,
I wanted to apply an OR condition for multiple roles using gs.hasRole() method.
However, I have a confusion about the syntax for the same :
gs.hasRole('role1' , 'role2' ); or gs.hasRole('role1,role2');
I am getting different results from these two syntaxes. Let me know what the difference is, and which is the correct one to check whether role1 OR role2 is present for the user.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2023 12:50 AM
Hi @Adamya Singh Pa ,
Note : The hasRole() returns true, if the user has the role specified (e.g. hasRole(role)) OR the admin role.
Reference :- https://servicenowguru.com/scripting/user-object-cheat-sheet/
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2023 02:00 AM
my bad.
yes it supports.
both the roles should be separated by comma
in your 1st method you are using comma separated values so it will work
but in your 2nd method you are combining both role names so system won't find any role with name as role1,role2
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2024 11:01 PM
you can pass 2 parameters if you use it in global scope, but in scoped use it accepts only one parameter.