Skip to content

Commit d09071b

Browse files
authored
Domain Separation Current Domain Display (#2262)
* Add script to show current domain on load * Add DomainCheckUtil to retrieve current domain name * Add README for Domain Separation Current Domain Display Added documentation for the Domain Separation Current Domain Display functionality, including an overview, components, methods, and usage instructions.
1 parent 87c4f9e commit d09071b

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var DomainCheckUtil = Class.create();
2+
DomainCheckUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
3+
//get current domain of user session
4+
getCurrentDomainName: function() {
5+
var sessionDomainId = gs.getSession().getCurrentDomainID();
6+
var gr = new GlideRecord('domain');
7+
if (gr.get(sessionDomainId)){
8+
return gr.name;
9+
}
10+
//Return global domain name
11+
return 'Global';
12+
},
13+
14+
type: 'DomainCheckUtil'
15+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Domain Separation Current Domain Display
2+
Overview
3+
This functionality provides real-time awareness to users about the current selected domain within ServiceNow's Domain Separation framework. It displays an informational message on form load indicating the active domain context, helping prevent accidental configuration or data entry in the wrong domain.
4+
5+
Components
6+
Script Include: DomainCheckUtil
7+
Global, client-callable Script Include allowing client scripts to query the current domain name via GlideAjax.
8+
9+
Methods:
10+
isCurrentDomain(domainSysId) — Checks if a given domain sys_id matches the current session domain.
11+
12+
Client Script
13+
An onLoad client script configured globally on the Global table, set to true to load on all forms.
14+
Calls the Script Include via GlideAjax to retrieve current domain name asynchronously.
15+
16+
Displays the domain name as an informational message (g_form.addInfoMessage) on the form header on every page load.
17+
18+
Usage
19+
Upon loading any record form, users see a message stating:
20+
"You are currently working in Domain Separation domain: [domain_name]."
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function onLoad() {
2+
var ga = new GlideAjax('DomainCheckUtil');
3+
ga.addParam('sysparm_name', 'getCurrentDomainName');
4+
ga.getXMLAnswer(showDomainMessage);
5+
function showDomainMessage(response) {
6+
var message = 'You are currently working in Domain Separation domain: <strong>' + response + '</strong>.';
7+
g_form.addInfoMessage(message);
8+
}
9+
}

0 commit comments

Comments
 (0)