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

I agree with rfedoruk.   I cannot see a way to do this as if you hide the parent group, then any children are hidden too.


Vichu
Mega Expert

Is there is a solution for this ? 

"Ticket should be assigned only to the child groups and not to the parent groups."

Vichu
Mega Expert

Hi Patrick, did you get a solution for this ?

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