Creating a reference qualifier to show members of the selected assignment group and other groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 06:37 AM - edited 06-19-2023 06:52 AM
On the below form, I'm wanting to add an amendment to the filter within the 'Assigned to' field:
However, what I'm wanting to do is that when an Assignment Group is selected then the 'Assigned to' field must display the members of that Assignment Group, as well as members of the Markets Run Teams or Markets Admin Groups. The 'Dependent' field in the Dictionary entry is already set to 'assignment_group', so I was just wondering how I could the search for members of Markets Run Teams or Markets Admin Groups.
I've tried using the following reference qualifier, but it's not worked:
groups=current.assignment_group^ORgroups=428d52301b62d550d1c4dbd6b04bcb27^ORgroups=58532b411b67e950ee611068b04bcbe0^EQ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 07:21 AM
Remove the dependent field on assigned_to field
Write a script include like below to show users who are either part of the selected Assignment Group or the Markets Run Teams group or Markets Admin Group (make changes necessary so that group names are correct)
// Get the selected Assignment Group value
var assignmentGroup = current.assignment_group;
// Create a reference qualifier to filter 'Assigned to' choices
var referenceQualifier = '';
// Get the sys_ids of users from the selected Assignment Group
var assignmentGroupUsers = new GlideRecord('sys_user_grmember');
assignmentGroupUsers.addQuery('group', assignmentGroup);
assignmentGroupUsers.query();
var assignmentGroupUsersSysIds = [];
while (assignmentGroupUsers.next()) {
assignmentGroupUsersSysIds.push(assignmentGroupUsers.user.toString());
}
// Get the sys_ids of users from the "Markets Run Teams" group
var marketsRunTeamsUsersSysIds = [];
var marketsRunTeamsGroup = new GlideRecord('sys_user_group');
if (marketsRunTeamsGroup.get('name', 'Markets Run Teams')) {
var marketsRunTeamsUsers = new GlideRecord('sys_user_grmember');
marketsRunTeamsUsers.addQuery('group', marketsRunTeamsGroup.sys_id);
marketsRunTeamsUsers.query();
while (marketsRunTeamsUsers.next()) {
marketsRunTeamsUsersSysIds.push(marketsRunTeamsUsers.user.toString());
}
}
// Get the sys_ids of users from the "Markets Admin Group"
var marketsAdminGroupUsersSysIds = [];
var marketsAdminGroup = new GlideRecord('sys_user_group');
if (marketsAdminGroup.get('name', 'Markets Admin Group')) {
var marketsAdminGroupUsers = new GlideRecord('sys_user_grmember');
marketsAdminGroupUsers.addQuery('group', marketsAdminGroup.sys_id);
marketsAdminGroupUsers.query();
while (marketsAdminGroupUsers.next()) {
marketsAdminGroupUsersSysIds.push(marketsAdminGroupUsers.user.toString());
}
}
// Combine all the user sys_ids into a single array
var allUserSysIds = assignmentGroupUsersSysIds.concat(marketsRunTeamsUsersSysIds, marketsAdminGroupUsersSysIds);
var arrayUtil = new ArrayUtil();
var uniqueUserSysIds = arrayUtil.unique(allUserSysIds);
// Add the condition to filter 'Assigned to' choices
return 'sys_idIN' + uniqueUserSysIds.join(',');
Call the script include include in the advanced reference qualifier on assigned to field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 07:52 AM - edited 06-19-2023 07:56 AM
Hi @Manmohan K What would I need to put within the 'Reference Qualifier' field? This is what I've added, but it's not working:
I've amended the code so that it's the below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 07:57 AM
Use below code in advanced reference qualifier
javascript: new ScriptIncludeName().functionName(current.assignment_group);
Pass assignment group in braces if needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 08:01 AM - edited 06-19-2023 08:01 AM