gs.hasRoleExactly('itil') is returning undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 10:59 PM
Hi All,
gs.hasRoleExactly('itil'), is returning undefined. But gs.hasRole('itil') is returning true please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 11:04 PM
There is no function gs.hasRoleExactly() in Glide System API. Glide System API has gs.hasRole() function available so it shows true.
hasRoleExactly() function is available in g_user client side API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 11:09 PM - edited 03-04-2024 11:10 PM
No do we have it in GlideSystem as well, i had used it recently.
you can also have look on below thread:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 11:13 PM
Hi check below link for better understanding
gs.hasRole('itil'): This function checks if the current user has any of the roles listed, including "itil" and potentially others. It returns true if the user has at least one of the listed roles, including "admin" which grants access to most functionalities.
gs.hasRoleExactly('itil'): This function checks if the current user has only the "itil" role and no other roles. It returns true only if the user has "itil" and no additional roles.
https://blog.snowycode.com/post/user-object-cheat-sheet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 11:24 PM
I created sample user, with just itil role, its still returning undefined. And also please let me know if my understanding is correct regarding 'hasRole' and 'hasRoleExactly'.
1. hasRole('itil'), return true if user has 'itil'/'admin' role.
2. hasRoleExactly('itil'), return true if user has 'itil' role and also some other roles but not admin role.