Scripted Filter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
15 hours ago
Hi,
I am trying to create a report which will show me a list of the ISSUES (sn_grc_issue) where the assignee is not a member of the assignment group (scenario: the assignee changes the group membership and someone else should get assigned to the issue).
I tried the following:
1. Create a script include
2/ Create a report with the condition:
SYS ID /IS ONE OF/ javascript:getInvalidIssues() ;
this does not work. Any suggestions?
Script Include:
function getInvalidIssues() {
var invalidIssues = [];
var grIssue = new GlideRecord('incident');
grIssue.addNotNullQuery('assigned_to');
grIssue.addNotNullQuery('assignment_group');
grIssue.query();
while (grIssue.next()) {
// Check if the assignee is a member of the assignment group
var isMember = false;
var groupMember = new GlideRecord('sys_user_grmember');
groupMember.addQuery('group', grIssue.assignment_group);
groupMember.addQuery('user', grIssue.assigned_to);
groupMember.query();
if (groupMember.next()) {
isMember = true;
}
// If not a member, include the issue sys_id in the array
if (!isMember) {
invalidIssues.push(grIssue.sys_id.toString());
}
}
return invalidIssues;
}
Report filter:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
15 hours ago
your script include should be client callable.
Also update this line
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
I adapted both, nothing has changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
Also I saw the in different sources that function is called in different ways. In my filter im using: javascript: functionName();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
@dev_K
is it client callable and sandbox enabled?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
