- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 08:26 PM
With domain separated records with overrides, I know that the overrides are obeyed using glideRecord.element.getRefRecord() (e.g. for a workflow or UI policy),
but is it possible to do so as part of a GlideQuery?
E.g. using gr.get(some_sys_id) to ultimately return the nearest domain override for a domain.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2016 12:04 AM
I've been able to get around the issue by walking down the sys_overrides chain (A overrides B overrides C), and checking domain visibility every step along the way.
It's not efficient but it does the trick. I'll try to neaten it up and provide it later.
Ideally, I'd love to know how ServiceNow does it natively like how it does with reference fields.
Top tip: Name all of the overrides the same for ease of querying (just query the same name, adding addDomainQuery for the target domain).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 08:37 PM
I think queryNoDomain() will do what you are looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 08:41 PM
Afraid that queryNoDomain() just removes any domain separation from the query, I'm after a way to return the final result after all overrides are applied.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 08:38 PM
This should be what you are looking for:
http://wiki.servicenow.com/index.php?title=GlideRecord#addDomainQuery&gsc.tab=0
An example is provided on the wiki page.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 10:03 PM
Does the wiki example not solve this problem?
var domain = new GlideRecord('sys_user');
domain.addQuery('user_name', 'itil');
domain.queryNoDomain();
if (domain.next()) {
var domainQuery = new GlideRecord('incident');
domainQuery.addQuery('active', true);
domainQuery.addDomainQuery(domain);
domainQuery.query();
gs.print('Number of Incidents for ITIL user: ' + domainQuery.getRowCount());
while (domainQuery.next())
gs.print(domainQuery.number);
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022