{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":166,"path":"api-reference/ScopedSessionDomainAPI.md","title":"ScopedSessionDomain - Client","bundle":null,"doc_type":null,"release":"australia","body":"\n# ScopedSessionDomain- Client\n\nThe ScopedSessionDomain script include that contains client-side methods that provide functionality related to the current session domain.\n\nThis 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.\n\n**Parent Topic:**[Client API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/api-client.md)\n\n## ScopedSessionDomain - getCurrentDomainID\\(\\)\n\nReturns the sys\\_id of the current domain for the logged-in user session.\n\nThe identifier that is returned depends on the domain type and the instantiation of that domain.\n\n-   If the user is configured in the global domain, and does not use the domain picker to switch domains, the method returns null.\n-   If the user uses the domain picker to switch to the global domain, the method returns the string \"global\".\n-   For all other domains, the method returns the sys\\_id of that domain.\n\nTo access this method from a client-side script, you must use [GlideAjax\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/c_GlideAjaxAPI.md) 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.\n\n```\nvar ssg = new global.ScopedSessionDomain(); \ndomainID = ssg.getCurrentDomainID();\n```\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Sys\\_id of the session domain of the current logged-in user. This is the same information that appears in the domain picker.|\n\nThis example shows how to call the getCurrentDomainID\\(\\) method from a client-side script.\n\n```\n// This example is calling the script include in a client script. \n// This particular record is within the \"Service Portal - Standard Ticket\" scope. \n// To reproduce this example: \n//  1. Change application scope to \"Service Portal - Standard Ticket\" \n//  2. Navigate to Client Script table and open a new form and name it anything \n//  3. Set table=ticket_configuration (this table is within the same scope) \n//  4. Set UI type=Desktop and Type=onLoad \n//  5. Populate the script field with the script above \n//  6. Navigate to the ticket_configuration table and open any form. \n//\n// 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\n\nfunction onLoad() {\t\n  var ga = new GlideAjax(\"global.ScopedSessionDomain\"); // Set the script include\n  ga.addParam(\"sysparm_name\", \"getCurrentDomainID\"); // Set the getCurrentDomainID method\n  ga.getXML(getResponse);\n\t\n  function getResponse(response) {\n     var answer = response.responseXML.documentElement.getAttribute('answer');\n     alert(answer); // Pops up the sys_id of the domain record\n  }\n}\n```\n\n"}}