- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 10:01 AM
Hi All,
I've already created an ACL that makes the Assigned To field writable only if the logged on user is a member of the current assignment group.
That's all good, except if I'm on the incident form and I am a member of the assignment group and I change the assignment group to one that I am not a member, the assigned to field will not change to readonly based on the ACL until I save the form.
I need a client script that can sense that I've selected a new assignment group in the GUI and at that very second the assigned to field needs to become read only because I'm no longer a member of the soon to be current assignment group.
What is the client script I should use for this or is there another way?
Thanks for the help.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 11:36 AM
Hi Jeffrey,
I like using onChange client scripts that call GlideAjax:
Client script (onChange of assignment group)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var thisUser = g_user.userID;
var ga = new GlideAjax('findAG'); //the script include
ga.addParam('sysparm_name','getUser'); //the function
ga.addParam('sysparm_user', thisUser);
ga.addParam('sysparm_grp', newValue); //the new AG
ga.getXML(getTheUser);
}
function getTheUser(response) {
var myAnswer = response.responseXML.documentElement.getAttribute("answer");
if(myAnswer == 'no') {
g_form.setReadOnly('assigned_to', true);
} else if(myAnswer == 'yes') {
g_form.setReadOnly('assigned_to', false);
}
}
Script include:
Name: findAG
Client Callable: yes
Script:
var findAG = Class.create();
findAG.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUser : function() {
var thisUser = this.getParameter('sysparm_user');
var thisGrp = this.getParameter('sysparm_grp');
var user = new GlideRecord('sys_user_grmember');
user.addQuery('group', thisGrp);
user.addQuery('user', thisUser);
user.query();
if(user.next()) {
return 'yes';
}
return 'no';
},
type: 'findAG'
});
harel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 10:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 10:38 AM
Jaspal,,
Thanks for the quick responses. Much appreciated.
I'm going to read through this link now and hopefully I can find a script that not only checks for is member of but does the readonly function.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 10:13 AM
Hello Jeffrey,
Why not restrict the assignment group choices list via reference qualifier? i.e show only the assignment group that user is member of
Reference Qualifiers - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 10:37 AM
If I'm a help desk agent I would always want to be able to select an assignment group even if I'm not a member of the assignment group, but I shouldn't be able to assign the incident to a person in any group that is not my group.
The ACL does good for this except not at the time I select an assignment group. It won't make the assigned to read only based on the ACL.
I'm going to read through the other link you provided for "is member of function in client script".
I'm a new SNOW developer (I've converted from BMC Remedy).
Scripts are my weakness still. I was able to script the ACL with is member of, but now I have to combine is member of with the script to make the assigned to read only.