ScopedSessionDomain - クライアント

  • リリースバージョン: Zurich
  • 更新日 2025年07月31日
  • 所要時間:3分
  • 現在のセッションドメインに関連する機能を提供するクライアント側のメソッドを含む ScopedSessionDomain スクリプトインクルード。

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

    ScopedSessionDomain - getCurrentDomainID()

    ログインしているユーザーセッションの現在のドメインの sys_id を返します。

    返される識別子は、ドメインタイプとそのドメインのインスタンス化によって異なります。
    • ユーザーがグローバルドメインで構成されていて、ドメインピッカーを使用してドメインを切り替えない場合、このメソッドは null を返します。
    • ユーザーがドメインピッカーを使用してグローバルドメインに切り替えると、このメソッドは文字列「global」を返します。
    • 他のすべてのドメインの場合、このメソッドはそのドメインの sys_id を返します。
    クライアント側スクリプトからこのメソッドにアクセスするには、GlideAjax() を使用して呼び出す必要があります。サーバー側スクリプトからこのメソッドを呼び出すには、次のようなコードを使用してオブジェクトをインスタンス化し、メソッドにアクセスします。
    var ssg = new global.ScopedSessionDomain(); 
    domainID = ssg.getCurrentDomainID();
    表 : 1. パラメーター
    名前 タイプ 説明
    なし
    表 : 2. 返される内容
    タイプ 説明
    文字列 現在ログインしているユーザーのセッションドメインの sys_id。これは、ドメインピッカーに表示される情報と同じです。

    この例は、クライアント側スクリプトから 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
      }
    }