- 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-19-2019 12:10 AM
Hi Asif, Hope you remember our discussion on variables tab restriction.
As of now its working correctly with your modified code.
So here me question is
once the task sets to closed complete on ritm form then only variables tab should be in read only mode.
Here is the script that we both are worked
Script include:
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'
});
Client script:
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_userID', g_user.userName);
ga.addParam('sysparm_groupName',g_form.getValue('assignment_group'));
ga.getXML(hideField);
//g_form.addInfoMessage("Entered into the function" +answer);
}
//g_form.addInfoMessage(g_user.hasRole('admin'));
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);
}
}
}
Can you help on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2019 12:26 AM
Hi Nag,
It is recommended that you open a new thread for a new question.
Regarding your question, in the below code jsut add your condition of the state of the RITM.
if ((answer == 'false') && !g_user.hasRole('admin')) {
g_form.setVariablesReadOnly(true);
}
else
{
g_form.setVariablesReadOnly(false);
}
If there is a follow up question, kindly open a new thread.
Mark the comment as helpful if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2019 12:31 AM
Can you elaborate and send me the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2019 12:43 AM
Can you elaborate and send me the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2019 12:57 AM
Replace your if and else condition in client script with the below code.
if ((answer == 'false') && !g_user.hasRole('admin') && g_form.getValue("state") ==3) {
g_form.setVariablesReadOnly(true);
}
else
{
g_form.setVariablesReadOnly(false);
}
Mark this comment and my earlier comment(s) as HELPFUL if it helps.
