Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var DomainCheckUtil = Class.create();
DomainCheckUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
//get current domain of user session
getCurrentDomainName: function() {
var sessionDomainId = gs.getSession().getCurrentDomainID();
var gr = new GlideRecord('domain');
if (gr.get(sessionDomainId)){
return gr.name;
}
//Return global domain name
return 'Global';
},

type: 'DomainCheckUtil'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Domain Separation Current Domain Display
Overview
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.

Components
Script Include: DomainCheckUtil
Global, client-callable Script Include allowing client scripts to query the current domain name via GlideAjax.

Methods:
isCurrentDomain(domainSysId) — Checks if a given domain sys_id matches the current session domain.

Client Script
An onLoad client script configured globally on the Global table, set to true to load on all forms.
Calls the Script Include via GlideAjax to retrieve current domain name asynchronously.

Displays the domain name as an informational message (g_form.addInfoMessage) on the form header on every page load.

Usage
Upon loading any record form, users see a message stating:
"You are currently working in Domain Separation domain: [domain_name]."
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function onLoad() {
var ga = new GlideAjax('DomainCheckUtil');
ga.addParam('sysparm_name', 'getCurrentDomainName');
ga.getXMLAnswer(showDomainMessage);
function showDomainMessage(response) {
var message = 'You are currently working in Domain Separation domain: <strong>' + response + '</strong>.';
g_form.addInfoMessage(message);
}
}
Loading