Incident ticket - show a restricted list of Category selection based on assignment group

Bret Smith
Giga Guru

I want to show a limited list of Category choices when a specific assignment group is selected.

 

show only categories that are for an assignment group to select.

If assignment group contains 'ACSES' only allow the following Category to be selected: ACSES

Dont want to show the other selections (Inquiry/Help, Software, Hardware, Network, Database, CORE)

BretSmith_0-1709068797081.png

 

3 REPLIES 3

Sanjeeva Reddy1
Giga Guru

Hi Bret,

 

You can achieve this by using the Client Script. The below code might help you.

 

Name: Category based on Assignment group

Table: Incident [incident]

UI Type: All

Type: onChange

Field Name: Assignment group

Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var assignGrp = g_form.getDisplayBox('assignment_group').value;
    // alert(assignGrp);

    if (assignGrp.indexOf('Studio') >= 0) {
        g_form.setValue('category', 'database');
        g_form.removeOption('category', 'network');
        g_form.removeOption('category', 'hardware');
        g_form.removeOption('category', 'software');
        g_form.removeOption('category', 'inquiry');
    }

}

 

If the answer has helped you, please mark the answer as correct/helpful.

 

Regards,

Sanjeeva.Y.Reddy.

Sanjeeva Reddy1
Giga Guru

Please try with your keyword, as for my testing I used the 'Studio' keyword.

Sumanth16
Kilo Patron

Hi @Bret Smith ,

 

Please modify the below script according to your field names:

 

Script include:

var GetUserGroup = Class.create();
GetUserGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	isGrpMember:function() {
		
		var gr = new GlideRecord('sys_user_grmember');
		var usrName = this.getParameter('sysparm_username');
		var grpName = this.getParameter('sysparm_groupName');
		gr.addQuery('user',usrName);
		gr.addQuery('group',grpName);
		gr.query();
		if(gr.next()) {
			gs.log('JC: match');
			return true;
		}
		else {
			gs.log('JC: no match');
			return false;
		}
	},
    type: 'GetUserGroup'
});

 

Client script:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
	
	var ga = new GlideAjax('GetUserGroup');
	ga.addParam('sysparm_name', 'isGrpMember');
	ga.addParam('sysparm_username', newValue);
	ga.addParam('sysparm_groupName','287ebd7da1fe198100f92cc8d1d2154e');
	ga.getXML(hideField);

	function hideField(response) {
		var answer = response.responseXML.documentElement.getAttribute("answer");
		if (answer == "false") {
		g_form.removeOption('team_selection', '2');
		}
	}

}

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda