Filtering Users based on the Group Membership in the list view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 04:43 AM
Hello Community,
I am trying to find out what are the options to achieve the following goal:
In the specific list (table) that contains column with User references, I want to be able to filter out records based on the Group Membership.
Example 1: In the Incident list, I want to be able to filter out all records where Caller is a member of the specific Group.
Example 2: In the Change Request list, I want to to be able to find all Changes Requested by members of the specific Group.
I am not looking for a generic solution that would work in all lists. It is fine if solution works for the specific Table.
Please, let me know if you have any suggestions.
Thank you in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:29 AM
Hi @Mike50,
Example 1: In the Incident list, I want to be able to filter out all records where Caller is a member of the specific Group.
Please use the below script:
Type: Business Rule
Table: Incident
When to run: Before
Operation: Query
Script:
Example 2: In the Change Request list, I want to to be able to find all Changes Requested by members of the specific Group.
Please use the below script:
Type: Business Rule
Table: Change Request
When to run: Before
Operation: Query
Script:
I hope this will solve your problem. Please mark it as Accepted and Helpful.
GoodWill,
Anshul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:31 AM
it depends on which field you want to apply filter and based on what condition.
Each table can and should have it's own filter condition.
what's your challenge for caller field on inciddent
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:32 AM
Hi @Mike50
It is not possible to have a filter in list views as described in the requirement. The possible option is using dynamic filter, if you have groups in single digit number you can create a dynamic filter for each group. You can refer the following docs.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 06:06 AM
Hello Mike,
I believe we cannot get to the group of the caller field as it is a related field to the caller field, so it might not be possible to filter out the records on incident table where caller is member of a specific group via filters in list view.
However, you can always use script to achieve the same.
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery("group", "287ebd7da9fe198100f92cc8d1d2154e"); //the group you choose
gr.query();
while(gr.next())
{
var inc = new GlideRecord('incident');
inc.addQuery("caller_id", gr.user);
inc.query();
while(inc.next())
{
gs.info(inc.number + ", " + inc.short_description);
}
}
I hope this answer helps you. Please mark it as correct and helpful, if it helps you. Thank you.