Dynamic reference qualifier based on other field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 12:09 AM
Hello All, I could use some help here.
I have a catalog item that has a reference variable on it called "System", referencing CMDB table. On CMDB table I have 2 fields: Owner and Owner Group.
What I need to achieve is to show only those entries in the System variable where "Requested for" is either an Owner of the CI or is part of the Owner Group specified on the CI. Can this be easily achieved through the reference qualifier?
Many thanks,
D.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 12:14 AM
Hi Dawid,
Yes you can use variables from the catalog item within a reference qualifier by specifying current.variables.your_variable_name
You will also need to add the following into the variable attributes section. This ensures your reference qualifier updates if the referenced field(s) are modified.
ref_qual_elements=<variable_name_here>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 12:24 AM
Hi,
Is requested_for a variable on your catalog item?
You will have to use advanced ref qualifier for this along with script include as you have to check the group membership of the Owner group for the requested for user
What did you start with?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 12:30 AM
That's a valid point. I don't have Requested For variable, so I should rephrase it to say I want currently logged user who is ordering an item to be a benchmark here - if he's the owner of the CI or is part of Owner group of this CI - he should be able to select it from the list and only those CIs, no other.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 12:56 AM
Hi,
then use this in script include advanced ref qualifier
javascript: getMyRecords();
function getMyRecords(){
var loggedInUser = gs.getUserID();
var arr = [];
var gr = new GlideRecord("cmdb_ci");
gr.addQuery("owned_by", loggedInUser); // use correct owner field
gr.query();
while (gr.next()) {
if(gs.getUser().isMemberOf(gr.support_group.toString())) // use correct field name here for owner group which refers to group table
arr.push(gr.getUniqueValue());
}
return 'sys_idIN' + arr.toString();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader