---
sourceDocument: Xanadu Now Platform の管理
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/platform-administration

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu Now Platform の管理

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# アサイン先グループフィールドを制限する

# アサイン先グループフィールドを制限する {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：3分

この例では、JavaScript とスクリプトインクルードで詳細参照修飾子を使用して、インシデントの \[アサイン先グループ\] の選択肢を \[アサイン先\] フィールドで指定されたユーザーを含むグループのみに制限する方法を示します。

## 始める前に

必要なロール：personalize_dictionary または admin

## 手順

1. インシデントを開きます。
2. \[アサイン先グループ\] のラベルを右クリックし、\[ディクショナリを構成\] を選択します。
3. フォームが \[デフォルトビュー\] の \[関連リンク\] に表示されている場合は、\[詳細ビュー\] をクリックします。
4. \[参照修飾子を使用\] フィールドで、\[詳細\] オプションが選択されていることを確認します。
5. \[参照修飾子\] フィールドに「<kbd class="ph userinput">javascript:new ReferenceQualifierHelper().backfillAssignmentGroup()</kbd>」と入力します。
6. レコードを保存します。
7. 移動先 システム定義スクリプトインクルード.
8. \[新規\] をクリックします。
9. スクリプトインクルードに <kbd class="ph userinput">ReferenceQualifierHelper</kbd> という名前を付けて、次のステップの JavaScript と一致させます。  
   この名前により、\[名前\] フィールドに基づいて API 名が正しく生成されます。
10. 次の JavaScript コードを使用した[スクリプトインクルード](https://www.servicenow.com/docs/access?context=c_ScriptIncludes&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US) 。  
    \[アクセス可能フォーム\] フィールドが環境に対して適切に設定されていることを確認します。

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

## 次のタスク

テストするには、インシデントを作成し、\[アサイン先\] フィールドでユーザーを選択します。\[アサイン先グループ\] ルックアップアイコンをクリックします。選択したユーザーを含むグループのみが表示されます。たとえば、データベースグループとネットワークグループに属する Bob Smith にインシデントを割り当てます。アサイン先グループに表示されるオプションは、\[データベース\] と \[ネットワーク\] のみです。

