how to find non admin user in service now

Nag9
Tera Expert

How to find non admin user in servicenow, he must have permissions to raise Ritm

1 ACCEPTED SOLUTION

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);

 

View solution in original post

93 REPLIES 93

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Nag,

Do you want how many users from sys_user table have admin and how many don't have admin?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Yes Ankur

Hi Nag,

 

For this you can use filter on sys_user_has_role table

use filter as role is admin; you would get a list of records then you can export it in excel etc

similarly apply filter as role is not admin

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur

My requirement is : I have 4 catalog items, all the items have same "grid task" is generated in ritm as first, Once the task changes to closed complete the variables tab on ritm form should be read only for all the users except the ADMINS and Y Group members.

 

For this i wrote script include and client script , I dont know whether its working properly are not, Could please check it once and let me know if any changes are their 

 

If is there any way to do the above requirement please provide the solution

 

Script include

 

var MyGroups = Class.create();
MyGroups.prototype = {
isGrpMember : function() {
var userID = this.getParameter('sysparm_userID');
var groupName = this.getParameter('sysparm_groupName');
var thisUser = gs.getUser().getUserByID(userID);
if (thisUser.isMemberOf(groupName)) {
return true;
}

else {

return false;
}
},
} type:'MyGroups';

 

Client script on ritm table

 

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')
{

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");
if ((answer == 'false') && !g_user.hasRole('admin')) {
g_form.setVariablesReadOnly(true);
}
else
{
g_form.setVariablesReadOnly(false);
}
}
}
}