---
sourceDocument: Xanadu ServiceNow AI Platform Administration
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/platform-administration

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Constrain the assignment group field

# Constrain the assignment group field {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

This example shows how to use an advanced reference qualifier with JavaScript and a
script include to restrict the incident Assignment group choices to
only the groups that contain the user specified in the Assigned to
field.

## Before you begin

Role required: personalize_dictionary or admin

## Procedure

1. Open an incident.
2. Right-click the Assignment group label and select Configure Dictionary.
3. If the form appears in Default view, under Related Links, click Advanced view.
4. In the Use reference qualifier field, ensure that the Advanced option is selected.
5. In the Reference qual field, enter <kbd class="ph userinput">javascript:new ReferenceQualifierHelper().backfillAssignmentGroup()</kbd>.
6. Save the record.
7. Navigate to System DefinitionsScript Includes.
8. Click New.
9. Name your script includes as <kbd class="ph userinput">ReferenceQualifierHelper</kbd> to match the Javascript in the following step.  
   This name ensures the API Name is generated correctly, based on the Name field.
10. [Script includes](https://www.servicenow.com/docs/access?context=c_ScriptIncludes&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US) with the following JavaScript code.  
    Ensure that the Accessible form field is properly set for the environment.

        var ReferenceQualifierHelper = Class.create();
        ReferenceQualifierHelper.prototype = {
        	
        	backfillAssignmentGroup:function() {
        		var assigneeGroupsQualifier = '';
        		var assignee = current.assigned_to;
        		
        		//return if the assigned_to value is empty (this causes all groups to be returned)
        		if(!assignee)
        			return;
        		
        		//sys_user_grmember has the user to group relationship
        		var grAssigneeGroups = new GlideRecord('sys_user_grmember');
        		
        		grAssigneeGroups.addQuery('user',assignee);
        		grAssigneeGroups.query();
        		
        		while(grAssigneeGroups.next()) {
        			if (assigneeGroupsQualifier.length == 0) {
        				// Create the beginning of the qualifier and add the 1st group
        				assigneeGroupsQualifier = 'sys_idIN' + grAssigneeGroups.getValue('group');
        			}
        			else {
        				// build a comma separated string of groups if there is more than one
        				assigneeGroupsQualifier += (',' + grAssigneeGroups.group);
        			}
        		}
        		// return Groups where assigned to is in those groups we use IN for lists
        		
        		gs.log('DP: RefQual = ' + assigneeGroupsQualifier);
        		
        		return assigneeGroupsQualifier;
        	},
        	type: 'ReferenceQualifierHelper'
        };

## What to do next

To test, create an incident and select a user in the Assigned to field. Click the Assignment group lookup icon. Only the groups that contain the user you selected appear. For example, you assign an incident to Bob Smith, who belongs to the Database group and the Networking group. The only options that appear in the assignment group are Database and Networking.

*[\>]: and then


