Domain scope in script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2017 01:33 PM
I have a custom table that will be used in all domains, and I need one of the fields to be unique across all domains. But the before business rule I wrote to restrict entering a value that has already been used is only searching for duplicates in the user's domain, rather than in all domains. How can I expand the domain scope in the script so that it searches for duplicates in all domains? The business rule is in 'global'.
(function executeRule(current, previous /*null when async*/) {
var dom = current.u_email_domain;
var rec = new GlideRecord('u_accepted_email_domains');
rec.addQuery('u_email_domain',dom);
rec.query();
if (rec.getRowCount() > 0)
{
current.setAbortAction(true);
gs.addErrorMessage('Email domain is already defined and cannot be used again.');
}
})(current, previous);
Thanks for any help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2017 11:17 AM
Thanks, I tried calling a script include but the records that are searched are still limited to those in the same domain. I believe the issue is that the scripts are running as the current user, who is restricted from seeing data in other domains.
I think I may have been making this hard than it has to be. If I set the dictionary field Unique to true, that should do the trick, right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2017 09:30 AM
Hi Karla,
Making a field unique could lead to loss of existent values of the field which i would not suggest. Script includes should work for domain access. Can you check the logs to see if there is anything odd happening at that timestamp? If not, a Hi ticket may be required to check it out further.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2018 12:06 PM
Just ran across this post again. Not sure how I fixed this particular issue 🙂 but
queryNoDomain();
bypasses any domain separation visibility issues and queries records in all domains.