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-05-2024 12:08 AM
It won't work on Script include.
Rather try :
var roles = gs.getUser().getUserByID().getRoles()+ '').split(',');
for(var i=0; i<roles.length; i++){
if(roles[i] == role ) return true;
}
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 04:06 AM
I tried as you suggested, Line 7 is only returning "taxonomy_admin" and the in above script 'if' condition evaluated to 'false' else part executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 04:28 AM
This should help in your understanding: https://www.servicenow.com/community/itsm-articles/uses-of-hasrole-methods-client-and-server-side/ta...
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark