---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://www.servicenow.com/docs/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# ScopedSessionDomain - クライアント

# ScopedSessionDomain - クライアント {#ariaid-title1}

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

現在のセッションドメインに関連する機能を提供するクライアント側のメソッドを含む ScopedSessionDomain スクリプトインクルード。

この API は、Domain Support - Domain Extensions Installer プラグイン (com.glide.domain.msp_extensions) がインスタンスでアクティブ化されている場合にのみ使用できます。また、この API にアクセスするには、発信者に管理者ロールが必要です。

## ScopedSessionDomain - getCurrentDomainID() {#ariaid-title2}

ログインしているユーザーセッションの現在のドメインの sys_id を返します。
返される識別子は、ドメインタイプとそのドメインのインスタンス化によって異なります。

* ユーザーがグローバルドメインで構成されていて、ドメインピッカーを使用してドメインを切り替えない場合、このメソッドは null を返します。
* ユーザーがドメインピッカーを使用してグローバルドメインに切り替えると、このメソッドは文字列「global」を返します。
* 他のすべてのドメインの場合、このメソッドはそのドメインの sys_id を返します。  
クライアント側スクリプトからこのメソッドにアクセスするには、[GlideAjax()](https://www.servicenow.com/docs/Atc_gXlIw3~k0vHCJpI8HA#c_GlideAjaxAPI "GlideAjax クラスを使用すると、クライアントスクリプトがスクリプトインクルードのサーバー側コードを呼び出すことができます。") を使用して呼び出す必要があります。サーバー側スクリプトからこのメソッドを呼び出すには、次のようなコードを使用してオブジェクトをインスタンス化し、メソッドにアクセスします。

    var ssg = new global.ScopedSessionDomain(); 
    domainID = ssg.getCurrentDomainID();

{#SSD-getCurrentDomainID__table_xrg_dfr_xnb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 1. パラメーター]

{#SSD-getCurrentDomainID__table_xrg_dfr_xnb} {#SSD-getCurrentDomainID__table_yrg_dfr_xnb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 現在ログインしているユーザーのセッションドメインの sys_id。これは、ドメインピッカーに表示される情報と同じです。 |
[表 : 2. 返される内容]

{#SSD-getCurrentDomainID__table_yrg_dfr_xnb}  
この例は、クライアント側スクリプトから getCurrentDomainID() メソッドを呼び出す方法を示しています。

    // This example is calling the script include in a client script. 
    // This particular record is within the "Service Portal - Standard Ticket" scope. 
    // To reproduce this example: 
    //  1. Change application scope to "Service Portal - Standard Ticket" 
    //  2. Navigate to Client Script table and open a new form and name it anything 
    //  3. Set table=ticket_configuration (this table is within the same scope) 
    //  4. Set UI type=Desktop and Type=onLoad 
    //  5. Populate the script field with the script above 
    //  6. Navigate to the ticket_configuration table and open any form. 
    //
    // This will trigger the client script, invoke the API, and pop up a browser alert containing the sys_id of the user's current domain

    function onLoad() {	
      var ga = new GlideAjax("global.ScopedSessionDomain"); // Set the script include
      ga.addParam("sysparm_name", "getCurrentDomainID"); // Set the getCurrentDomainID method
      ga.getXML(getResponse);
    	
      function getResponse(response) {
         var answer = response.responseXML.documentElement.getAttribute('answer');
         alert(answer); // Pops up the sys_id of the domain record
      }
    }


