Update reference qualifiers via script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2022 09:37 AM - edited ‎12-21-2022 12:19 PM
We are faced with this issue: in catalog items, it is sometimes necessary for the end user to select a user that is no longer active (for example, request to access the users data after they've already left the company). However, OOB ServiceNow does not allow end users to have visibility to inactive users so when asked to select the user whose data they need access to, they can't find them.* I've fixed that issue, but now I need to update the reference qualifier for all fields pointing to the user table (~5500) and add 'active=true'.
I've written this script to update one record to see what happens, but it doesn't make the change and I'm wondering what I'm missing.
var refqual = 'active=true';
var qs = 'use_reference_qualifier=simple^reference=sys_user^reference_qual_conditionNOT LIKEactive=true^ORreference_qual_conditionISEMPTY';
var d = new GlideRecord('sys_dictionary');
d.addEncodedQuery(qs);
d.query();
gs.print(d.getRowCount());
if (d.next()) {
if (d.reference_qual_condition != '') {
refqual = refqual + '^' + d.reference_qual_condition;
}
gs.print(d.element);
gs.print(d.name);
d.reference_qual_condition = refqual;
d.reference_qual = refqual;
d.autoSysFields(false);
d.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2022 09:52 AM
why not do the reverse? Use dictionary overrides for the catalog items where you require inactives

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2022 12:17 PM
I'm not sure what you mean - can you elaborate? The limitation isn't set in the dictionary, it's controlled by a user query business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2022 12:41 PM
I misunderstood/misspoke.
I assumed you did the workaround to check for active=true in the ref qual parameter.
No need to add active true, if you can default to true in your check (ternary operator), if active = false is found (should only come from that one catalog item) then bypass the current.addActiveQuery (or whatever that is, I am doing this from a distant memory).
I hope this makes sense ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2022 10:09 AM
I think instead of if (d.next()), you need to use while(d.next()) to update all the dictionary records.
Please mark this response as correct or helpful if it assisted you with your question.