- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
I have a catalog item variable that references "cmdb_ci_business_app".
Now, I want that variable to only show results that:
1. Are Active
2. Have the status "In Production"
3. Managed By Group, which must be one of the groups the person is a member of
If the person is a member of a specific group, say "SpecialGroup", then point 3 can be omitted.
How can I easily achieve this? I've tried several solutions, but nothing works.
Thanks!
Solved! Go to Solution.
- Labels:
-
ITSM: General
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
try this in advanced ref qualifier on that variable
-> ensure you replace your correct group name
-> ensure you replace : with : as there is a known issue when we reply in community it converts that character
javascript: var query = '';
if (gs.getUser().isMemberOf('SpecialGroup'))
query = 'active=true^install_status=1';
else {
var groupsArr = new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());
query = 'active=true^install_status=1^managed_by_group.sys_idIN' + groupsArr.toString();
}
query;
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Glad to know that my script worked.
yes getMyGroups() will show parent group also
for handling that you need to query sys_user_grmember and get exact group for that user
-> ensure you replace your correct group name
-> ensure you replace : with : as there is a known issue when we reply in community it converts that character
javascript:
var query = '';
if (gs.getUser().isMemberOf('SpecialGroup'))
query = 'active=true^install_status=1';
else {
var groupsArr = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("user", gs.getUserID());
gr.query();
while (gr.next()) {
groupsArr.push(gr.getValue('group'));
}
query = 'active=true^install_status=1^managed_by_group.sys_idIN' + groupsArr.toString();
}
query;
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Thanks @Ankur Bawiskar!
Sorry for the late reply, was a few days away. The first advanced reference qualifier works great. The second one, I will keep in mind. I'm sure I will need it again.
Best regards,