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' +}); 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]." 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); + } +}