Domain override via script

davidmcdonald
Kilo Guru

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.

1 ACCEPTED SOLUTION

davidmcdonald
Kilo Guru

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).


View solution in original post

7 REPLIES 7

It gets me half the way there, but there's the possibility of the overriding record having a different name than the higher-domain original. The issue is that it can track what the higher-domain original is, but it loses track of it once the domain perspective is changed to a lower domain due to the change in name.


I'm not sure, but maybe it is possible to add multiple domains to the query by adding based off the addDomainQuery hierarchy?



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

davidmcdonald
Kilo Guru

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).