hasRoleInGroup() is returning false although i am present in the group and getting role inherited from group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 12:03 AM
Hi all,
I am part of "test" group and this group has role "web_servcie_admin"
if(gs.hasRoleInGroup( 'web_service_admin', 'test')){
gs.print("true");}
else{
gs.print("false");
}
The background script is returning false.Please help me with this.
thanks,
Ramya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 12:15 AM
Hi,
Please make sure all 3 conditions were met (manually set inherited to false), the User Role record for the group successfully grants access.
Returns: Returns true if all of the following conditions are met:
- The logged-in user HAS the role in question.
- The "Granted by" field on the user role record is set to the specified group.
- The "inherited" field on the user role record is false.
Thanks,
Vinitha.K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 02:32 AM
Hi vinitha,
Thanks for your quick reply.
The granted by and inherited fields are read only. i cannot edit them
Thanks,
Ramya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 12:35 AM
Hi,
Try to test that code in the ui action since it is a sensing script. I think a background script runs on the server side which that code cannot reach the role of the current user.
Try putting it in the "Delete" button in the requested items and remove the code after testing. You can configure the ui aciton at the bottom by right clicking your desired button like this:
Then, add that code in the ui action.
If you expect the result in that code will be TRUE, the button will appear. Else, the button will not appear.
Hope this helps.
Thank you,
a.c.manlangit
serviceNow Developer - Philippines