- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 12:08 AM
How to find non admin user in servicenow, he must have permissions to raise Ritm
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 03:57 AM
Can you add the log statement in the script include after this line and tell me the log output.
var thisUser = gs.getUser().getUserByID(userID);
gs.log("Group name is "+groupName+"----"+userID);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 11:14 PM
Hi Nag,
I just made few changes. Here is the updated script include. Try this and let me know the output.
var MyGroups = Class.create();
MyGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isGrpMember:function() {
var userID = this.getParameter('sysparm_userID');
var groupID = this.getParameter('sysparm_groupName');
//get the group name based on the group id
gs.log("Entered the function of isGRP Member");
var gr = new GlideRecord("sys_user_group");
gr.addQuery("sys_id",groupID);
gr.query();
if (gr.next()) {
gs.log("Enered into the if condition of my script include");
var groupName = gr.getValue("name");
var thisUser = gs.getUser().getUserByID(userID);
if (thisUser.isMemberOf(groupName)) {
gs.log("Returned true becuase user is member of this group");
return true;
}
else {
gs.log("Returned false because user is not a member of this group");
return false;
}
} // end of if gr.next
},
type:'MyGroups'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 11:18 PM
Modified the script include
Below is the output im getting in client script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 11:21 PM
So you got answer as false, which means the user is not a member of the group.
But the 2nd one returned true, which mean sthe user whom you are checking this is admin. so it returned true.
!true = false, hence it is not entering your if condition in the client script.
check with any other non-admin user once.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 11:32 PM
Hi Nag,
Did you check as non-admin user?
If yes, kindly mark my comment as a correct answer and all my other comments as helpful if this has helped you in solving it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 11:36 PM
yes checking give 10 mins time