ScopedSessionDomain :クライアント

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

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

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