based on group want to display service accounts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2025 10:18 AM
There are 2 variables in catalog form one is group and 2 is service account based on selected group i need to show service accounts which are present in selected group. And also want to check if the requested for is the manager of the group them RITM should auto-approve else it should go the group maanger approval.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2025 10:57 PM
Hi @srikanthr066535
1. Create one script include as below to get the group members list.
var SJCatalogUtils = Class.create();
SJCatalogUtils.prototype = {
initialize: function() {},
getUsers: function(groupId) {
var userArr = [];
var grp_member = new GlideRecord('sys_user_grmember');
grp_member.addQuery('group', groupId);
grp_member.addEncodedQuery('user.nameLIKEService Account');
grp_member.query();
while (grp_member.next()) {
userArr.push(grp_member.user.sys_id);
}
return 'sys_idIN'+userArr.toString();
},
type: 'SJCatalogUtils'
};
2. Use "Advanced Reference qualifier" to fetch the service accounts by passing the group sys_id from the previous variable.
javascript: new global.SJCatalogUtils().getUsers(current.variables.select_group);
Regarding the auto-approval process, before triggering the approval, use a script action if you're working with a workflow, or an "if" condition if you're using Flow Designer, to verify that group.manager == requested_for.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2025 11:44 PM
Service account is a true/false field if it is true then i need to show in service account
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2025 11:14 PM
so you want group members in 2nd variable and 2nd variable is referring to sys_user?
If yes then you can use this in advanced ref qualifier
javascript: var query = '';
var arr = [];
var memberRec = new GlideRecord('sys_user_grmember');
memberRec.addQuery('group', current.variables.groupVariableName);
memberRec.addEncodedQuery('user.nameLIKEService Account'); // give your encoded query here
memberRec.query();
while (memberRec.next()) {
arr.push(memberRec.getValue('user'));
}
query = 'sys_idIN' + arr.toString();
query;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2025 11:48 PM
Yes it's a reference to Group member if i select any group in Group field i want to show service account which are present in that group Service account is a True/false field in user table