Query Business rule based on assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2020 05:17 AM
Hi Team,
I am writing the query Business rule. Where if Logged in user is member of that group, then only incidents belongs to that assignment group should be visible.
Before query business rule on Incident.
it works when I send Sys_id of that group example:
if(gs.getUser().isMemberOf('f795ab34db230010bdfd0181ca96196b'))
{
current.addQuery('assignment_group','f795ab34db230010bdfd0181ca96196b');
}
Its Not working below one.
if(gs.getUser().isMemberOf(current.assignment_group))
{
current.addQuery('assignment_group',current.assignment_group);
}
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2020 02:18 AM
Hi Pooja,
Verify if current.assignment group is showing the right sys_id or not. I have added logs. below check once.
gs.log("Assignment group is "+current.assignment_group);
if(gs.getUser().isMemberOf(current.assignment_group))
{
gs.log("Entered into this");
current.addQuery('assignment_group',current.assignment_group);
}
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2020 02:20 AM
Hi,
please follow this links:
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy.
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2020 03:35 AM
Hi Pooja,
Try using getUniqueValue() function, please find the updated script below:
if(gs.getUser().isMemberOf(current.assignment_group.getUniqueValue()))
{
current.addQuery('assignment_group',current.assignment_group.getUniqueValue());
}
Kindly mark my answer as Correct and helpful based on the Impact.
Regards,
Alok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2020 09:53 AM
Hi,
If with current statement it's not working and you need to pass sys_id as value, create a property with the sys_id of the group and call it inside script as follows:
if(gs.getUser().isMemberOf(gs.getProperty('propertyName')){
current.addQuery('assignment_group',propertyName);
}
//Also if you want to check over more than one group try this.
var groups = gs.getUser().getMyGroups().split(',');
if(groups.indexOf(gs.getProperty('propertyNanme').toString()) != -1)
{
current.addQuery('assignment_group', 'IN', groups.join());
}
Is it was helpful, please give positive feedback.
Thanks,
☆ Community Rising Star 22, 23 & 24 ☆