Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Scripted Filter

dev_K
Tera Contributor

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:

dev_K_0-1762354482208.png

 

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@dev_K 

your script include should be client callable.

Also update this line

    return invalidIssues.toString();
Also ensure the sandbox enabled checkbox is true
AnkurBawiskar_0-1762355479088.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

dev_K
Tera Contributor

I adapted both, nothing has changed.

 

dev_K_0-1762356510354.png

 

dev_K
Tera Contributor

Also I saw the in different sources that function is called in different ways. In my filter im using: javascript: functionName();

 

dev_K_1-1762356730534.png

 

@dev_K 
is it client callable and sandbox enabled?

AnkurBawiskar_0-1762357272417.png

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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