based on group want to display service accounts

srikanthr066535
Tera Contributor

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.

8 REPLIES 8

Service Account is True/false field if it is true then i need to show those service accounts only which are present in the group

@srikanthr066535 

Ensure your variable refers to sys_user and not sys_user_grmember table

what do you mean by service account is true/false field?

Are you saying you want only those users from that group which are having that field as true?

If yes then update as this

javascript: var query = '';
var arr = [];
var memberRec = new GlideRecord('sys_user_grmember');
memberRec.addQuery('group', current.variables.groupVariableName);
memberRec.addEncodedQuery('user.serviceAccountField', true); // 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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

i need to get the service accounts part of that selected group. service Account is a true/false field in user table and we added those profiles to few groups 

for example: if i selected It support group then i need to show only Service accounts part of that It support group

Service Account is True/false field if it is true then i need to show those service accounts only which are present in group