---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# ScopedSessionDomain - Client

# ScopedSessionDomain - Client {#ariaid-title1}

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

The ScopedSessionDomain script include that contains client-side methods that provide functionality related to the current session domain.

This API is only available if the Domain Support - Domain Extensions Installer plugin
(com.glide.domain.msp_extensions) plugin has been activated in the instance. In addition, the
caller must have the admin role to access this API.

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

Returns the sys_id of the current domain for the logged-in user session.
The identifier that is returned depends on the domain type and the instantiation of that domain.

* If the user is configured in the global domain, and does not use the domain picker to switch domains, the method returns null.
* If the user uses the domain picker to switch to the global domain, the method returns the string "global".
* For all other domains, the method returns the sys_id of that domain.  
To access this method from a client-side script, you must use [GlideAjax()](https://servicenow-prod.fluidtopics.net/9y18iKKIcWAq_NDuR_8fzQ#c_GlideAjaxAPI "The GlideAjax class enables a client script to call server-side code in a script include.") to invoke it. To invoke this method from a server-side script, use something similar to the following to instantiate the object and access the method.

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

{#SSD-getCurrentDomainID__table_xrg_dfr_xnb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

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

| Type | Description |
|-|-|
| String | Sys_id of the session domain of the current logged-in user. This is the same information that appears in the domain picker. |
[Table 2. Returns]

{#SSD-getCurrentDomainID__table_yrg_dfr_xnb}  
This example shows how to call the getCurrentDomainID() method from a
client-side script.

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


