The CreatorCon Call for Content is officially open! Get started here.

Don't allow assignment to specific groups

patrickmcgonagl
Giga Expert

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

1 ACCEPTED SOLUTION

patrickmcgonagl
Giga Expert

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

View solution in original post

13 REPLIES 13

What advantage does the tree picker provide your users?  



I only ask because I usually go to non-tree picker and makes reference qualification less of a nightmare.


they can see who is in a group or what group that group belongs to.   sometimes they might know who should be working on an issue but they might not know the group name and it gives them another way to see the hierarchy in case they need to


I would possibly look at the following


Create an onchange client script for the Assignment group.


that looks at the list of members of the assignment group and if there are no members it puts an field error message up asking the user to reselect


we want to avoid using client scripts if possible, but that might work.   The only thing is that not all the groups are empty.   they usually have VP's in them and they use the top level group for reporting on all their teams that are sub groups, not working on issues.


There's no mechanic I know of that can both present a tree view, but prevent you from selecting a parent record.   The best you can do in this situation is present a post-selection error message that tells the user they can't pick a parent.