- 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 06:16 AM
Yes tried info message same Message showing null
I think because of im an admin??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 06:47 AM
This line should return true to you as you are admin.
g_user.hasRole('admin')
I see there are few issues in your script include and client scripts. I have updated them here.
1. Your script include is not checked as client callable.
2. you are passing group_id to script include but isMemberof accepts group name.
I have modified your code slightly. Try this once and tell me what is the output.
function onLoad() {
//Type appropriate comment here, and begin script below
var item=g_form.getValue('cat_item');
if (item=='e7d48d55db5f8b00c77b7016bf96199b' || item=='e386bfb3dba68700c77b7016bf961943' || item =='ae244264dbb6c700c77b7016bf961944' || item== '1813429bdb83c700f3e5f156bf9619e9' || item== '0d0c3f5adb28e3001ac0105f6896198e' || item =='f2377d15db9f8b00c77b7016bf96191c' || item=='f477b155db9f8b00c77b7016bf961967')
{
g_form.addInfoMessage("Entered into if condition");
var ga = new GlideAjax('MyGroups');
ga.addParam('sysparm_name', 'isGrpMember');
ga.addParam('sysparm_userID', g_user.userID);
ga.addParam('sysparm_groupName',g_form.getValue('assignment_group'));
ga.getXML(hideField);
function hideField(response) {
var answer = response.responseXML.documentElement.getAttribute('answer').toString();
g_form.addInfoMessage("Entered into the function" +answer);
g_form.addInfoMessage(g_user.hasRole('admin'));
if ((answer == 'false') && !g_user.hasRole('admin')) {
g_form.setVariablesReadOnly(true);
}
else
{
g_form.setVariablesReadOnly(false);
}
}
}
}
Script Include
var MyGroups = Class.create();
MyGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
initialize:function() {
},
isGrpMember:function() {
var userID = this.getParameter('sysparm_userID');
var groupID = this.getParameter('sysparm_groupName');
//get the group name based on the group id
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';
});
check system logs as well to check if you are getting the gs log statements and sharre me the otuput if it does not work.
Mark the comment as a correct answer and also helpful once worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 11:04 PM
Its not working asif, Still anon admin user able to edit the varaibles

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 11:06 PM
Hello Nag,
First tell me what is the output you have seen based on the script that i shared? Did you update both the scripts that i shared?
Did you make the script include "client callable" checked?
In the logs is it returning the correct value?
What is the output of the client scirpt?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 11:10 PM