From 97fd3ddc9c3020ae8a8957320401c7a8edcec87f Mon Sep 17 00:00:00 2001 From: Charanjeet <35090930+Charanjet@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:43:40 +0530 Subject: [PATCH 1/3] Add script to show current domain on load --- .../Show Current Domain/Show Current Domain.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Show Current Domain/Show Current Domain.js diff --git a/Client-Side Components/Client Scripts/Show Current Domain/Show Current Domain.js b/Client-Side Components/Client Scripts/Show Current Domain/Show Current Domain.js new file mode 100644 index 0000000000..f59f5df1e0 --- /dev/null +++ b/Client-Side Components/Client Scripts/Show Current Domain/Show Current Domain.js @@ -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: ' + response + '.'; + g_form.addInfoMessage(message); + } +} From 3da240b5953325530ea98bfbbd576e8e1808e6ae Mon Sep 17 00:00:00 2001 From: Charanjeet <35090930+Charanjet@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:46:29 +0530 Subject: [PATCH 2/3] Add DomainCheckUtil to retrieve current domain name --- .../Show Current Domain/DomainCheckUtil.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Show Current Domain/DomainCheckUtil.js diff --git a/Client-Side Components/Client Scripts/Show Current Domain/DomainCheckUtil.js b/Client-Side Components/Client Scripts/Show Current Domain/DomainCheckUtil.js new file mode 100644 index 0000000000..9b5ef69bb2 --- /dev/null +++ b/Client-Side Components/Client Scripts/Show Current Domain/DomainCheckUtil.js @@ -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' +}); From d007912123150a27cb476a100c0285755f1472b3 Mon Sep 17 00:00:00 2001 From: Charanjeet <35090930+Charanjet@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:50:32 +0530 Subject: [PATCH 3/3] 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. --- .../Show Current Domain/Readme.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Show Current Domain/Readme.md diff --git a/Client-Side Components/Client Scripts/Show Current Domain/Readme.md b/Client-Side Components/Client Scripts/Show Current Domain/Readme.md new file mode 100644 index 0000000000..6c5bc08b5d --- /dev/null +++ b/Client-Side Components/Client Scripts/Show Current Domain/Readme.md @@ -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]."