- 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 11:07 AM
Thanks for the update. In that case, I would recommend you to create a OnChange client script + GlideAjax. More info on GlideAjax
How to Write Smart GlideAjax Quickly
You can copy the script from other link and adjust it accordingly.
- 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 11:56 AM
Harel,
That script is very nice.
I appreciate you sharing it with me.
It's tough being the new guy.
I feel like I'm cheating when I have to ask someone for help.
The script is working perfectly.
I hope to return the favor some day.
Jeff Mangan