JavaScript example: Constraining the assignment group field

This example shows how to restrict an incident's Assignment group choices to only the groups that contain the user already specified in the Assigned to field.

  1. Open an incident.
  2. Right-click the Assignment group field and select Configure Dictionary.
  3. If the form appears in Default view the Related Links list, click Advanced view.
  4. In the Use reference qualifier field, ensure that the Advanced option is selected.
  5. In the Reference qual field, enter javascript:new BackfillAssignmentGroup().BackfillAssignmentGroup().
  6. Save the record.
  7. Navigate to System Definitions > Script Includes.
  8. Click New.
  9. Create a script include with the following JavaScript code:
    var BackfillAssignmentGroup = Class.create();
    BackfillAssignmentGroup.prototype = {
    	initialize: function() {
    	BackfillAssignmentGroup:function() {
    		var gp = ' ';
    		var a = current.assigned_to;
    		//return everything if the assigned_to value is empty
    		//sys_user_grmember has the user to group relationship
    		var grp = new GlideRecord('sys_user_grmember');
    		while( {
    			if (gp.length > 0) {
    				//build a comma separated string of groups if there is more than one
    				gp += (',' +;
    			else {
    				gp =;
    		// return Groups where assigned to is in those groups we use IN for lists
    		return 'sys_idIN' + gp;
    	type: 'BackfillAssignmentGroup'

    The next time you create an incident, select a user in the Assigned to field. Then click the Assignment group lookup icon. Only the groups that contain the user you just selected appear. For example, if Bob Smith belongs to the Database group and the Networking group and you assign an incident to Bob, the only options you can select for the assignment group are Database and Networking.