- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2015 11:58 AM
This question is similar to the one asked here Don't allow case to be submitted to empty assignment group but the organizational groups that we have tend to have at least one member in them to allow them to see all sub groups work when looking at "My Groups Work". What we would like to do is not allow an assignment to higher level groups based on a true/false field on the groups table
under form design I created a true/false field name Organizational Group (u_org_group) and after setting the value on the necessary groups would change it to Read Only
the pseudo code that I have is
on change group assignment
if u_org_group in sys_user_group is true
then alert "This is an organizational group, please assign to a different group." and assign to previous group or set to null
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2020 05:50 AM
We used an onChange client script that calls a script include, another requirement that was added was that only members of those groups would be allowed to assign to the group.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue){
var ajax = new GlideAjax('noAssignGroupUtils');
ajax.addParam('sysparm_name', 'getAssignGroup');
ajax.addParam('sysparm_assign_group',newValue);
ajax.getXML(updateQueue);
}
function updateQueue(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer){
g_form.clearValue('assignment_group');
g_form.showFieldMsg('assignment_group','You cannot assign a ticket to ' + answer + ' group','error');
alert("You cannot assign a ticket to this group");
return false;
}
}
}
var noAssignGroupUtils = Class.create();
noAssignGroupUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getAssignGroup: function(){
var group = new GlideRecord("sys_user_group");
if(group.get(this.getParameter('sysparm_assign_group'))){
if(group.u_no_assign == true) {
if(gs.getUser().isMemberOf(this.getParameter('sysparm_assign_group')) || gs.getUser().hasRole('admin'))
return;
return group.getDisplayValue();
}
return;
}
},
type: 'noAssignGroupUtils'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2015 06:00 PM
If you want to disallow assignment to these groups it would make more sense to prevent users from being able to select them in the first place by means of a reference qualifier.
You can then simply add the condition mentioned above.
Prevention is better than a cure.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2015 05:06 AM
When I tried this out it would hide not only the top level group but all its subgroups as well. We need to prevent assignments only to the top level groups, but still allow assignments to it subgroups.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2015 07:06 AM
Are you using tree view for your group selection?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2015 07:33 AM
yes we do use the tree view and/or just type in the group name to search