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

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

An End user can also raise and RITM using catalog and portal. What is your ask?


THanks
Ashutosh

Hi ashutosh,

 

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

asifnoor
Kilo Patron

Hello Nag,

By default, an end user can also raise RITM.

If you want to know all non-admin users, then you can simply go to sys_user.list and then add a filter Roles is not admin. it will give you all non-admin users.

Mark answer as correct if this answers your question.

Hi Nag,

Did you check my solution given above?

Hi Asif

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