How to get current domain on UI page in scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2015 03:40 AM
How can I get currently active domain to show its display value on UI page in scoped app?
What I have for now:
1. queryNoDomain is not allowed in scoped app, so I cannot use to get list of ALL domains, as it will return a list of subdomains of current domain.
var gr_domain = new GlideRecord('domain');
gr_domain.addQuery('active', true);
gr_domain.query();
if (gr_domain.next()) {
// this will show only subdomains, as this query runs in domain scope.
// I would like to show the list of all domains as it is done in domain_select macro.
}
2. I tried to include macro
<g:macro_invoke macro="domain_select" />
in UI page, I get the error:
Uncaught ReferenceError: GlideManager is not defined
3. Also I tried to use DomainSelect script include, but it is not allowed in scoped app.
How can I make my scoped app work in domain separated env if things related to domain separation are not allowed in scoped application?
I would like to be able to, at least, get currently active domain and show its display value on the page.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2016 06:34 AM
Hi Andriy,
I had the same issue, wanting to show the user's domain (for debugging in my case) as well as trying to queryNoDomain on the GlideRecord.
The solution was to create a script include (or two) in the global domain and make it accessible to all application scopes. For the queryNoDomain solution, the method within the script include looks like this:
queryNoDomain: function(glideRec) {
var newRec = new GlideRecord(glideRec.getTableName());
newRec.addEncodedQuery(glideRec.getEncodedQuery());
newRec.queryNoDomain();
return newRec;
}
You pass in the GlideRecord you want to query from your scoped application, create a new one in the global scope, copy the query, execute the queryNoDomain method, and then return the freshly queried GlideRecord back to your application. I used the same method to return gs.getUser().getDomainDisplayValue() (except all you need to do is put "return" in front of that code for the body of your method).
I hope you find this helpful.
Thanks,
Nick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2021 08:17 AM
Hi Nyancer,
I am facing the same issue queryNoDomain not working. Can you please guide how i can use the above code.
Please see my background script, i want to update in each domain but now only its updating in global domain. Thanks in advance
var gr =new GlideRecord('x_lini_tm_asset_properties');
gr.addEncodedQuery('product.nameLIKEasset' );
gr.query();
if(gr.next()){
gr.total_extension_duration=0;
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}