Creating a report with <20 tasks assigned to specific assignment groups

itd87
Tera Expert

Hello, 

 

I am trying to create a report to show the results of select assignment groups with fewer than 20 tasks (incident, change, problem) assigned to them in the past year. My goal is to see which teams in my company are not using ITSM. 

 

The part I'm struggling with is limiting my results to those with fewer than 20 tasks. I hoped I could use the report's aggregation count value as a variable in the filters, but I'm unable to do that.  

 

Any advice or thoughts on this would be greatly appreciated. Thank you! 

1 ACCEPTED SOLUTION

Hemanth M1
Giga Sage
Giga Sage

Hi @itd87 ,

 

You can do this in a more dynamic way but need to configure couple of things 

1)Create a report on task table (List type report) and group by Assignment Group

HemanthM1_0-1703245037174.png

 

 

2)Create Script include (Client callable script include as below)

HemanthM1_1-1703245200286.png

Script here:

 

var getCount = Class.create();
getCount.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    assignment_group_count: function() {
        var agName = "";
        var gr = new GlideAggregate("task") 
        gr.addAggregate("COUNT");
        gr.groupBy("assignment_group");
        gr.query();
        while (gr.next()) {
            var count = gr.getAggregate("COUNT"); //count of the each assignment group 
            if (count < 11) { //only get assignment group has 10 or fewer records
                agName = agName + "," + gr.getDisplayValue("assignment_group");
            }
        }
        return agName.toString(); //retun the assignment group names

    },

    type: 'getCount'
});

 

3)go back to the report and add this filter condition

assignment group name is one of javascript&colon; new getCount().assignment_group_count() as below

save and run the report 😍, lt would only show assignment groups which 10 or less number of tasks

 

you can expand the check the records as well here.

 

this is scalable (you can change the count in the script include to get the different count and also you don't have to enter any assignment group manually to check.

 

HemanthM1_2-1703245390799.png

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

3 REPLIES 3

arielgritti
Mega Sage

Hi @itd87 
Try this.

Create a report in Group (sys_user_group) table.

In the "related list conditions" select Task (task) table with the condition "Less than or equal to" 20 and in the field select assignment_group for task table field.

 

Screenshot 2023-12-22 at 11.52.53.png

 

Please mark helpful or correct if I helped you.
This action will help other members with similar issues to find a solution.
Thanks
Ariel

Hemanth M1
Giga Sage
Giga Sage

Hi @itd87 ,

 

You can do this in a more dynamic way but need to configure couple of things 

1)Create a report on task table (List type report) and group by Assignment Group

HemanthM1_0-1703245037174.png

 

 

2)Create Script include (Client callable script include as below)

HemanthM1_1-1703245200286.png

Script here:

 

var getCount = Class.create();
getCount.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    assignment_group_count: function() {
        var agName = "";
        var gr = new GlideAggregate("task") 
        gr.addAggregate("COUNT");
        gr.groupBy("assignment_group");
        gr.query();
        while (gr.next()) {
            var count = gr.getAggregate("COUNT"); //count of the each assignment group 
            if (count < 11) { //only get assignment group has 10 or fewer records
                agName = agName + "," + gr.getDisplayValue("assignment_group");
            }
        }
        return agName.toString(); //retun the assignment group names

    },

    type: 'getCount'
});

 

3)go back to the report and add this filter condition

assignment group name is one of javascript&colon; new getCount().assignment_group_count() as below

save and run the report 😍, lt would only show assignment groups which 10 or less number of tasks

 

you can expand the check the records as well here.

 

this is scalable (you can change the count in the script include to get the different count and also you don't have to enter any assignment group manually to check.

 

HemanthM1_2-1703245390799.png

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

itd87
Tera Expert

Thank you for this solution! This is exactly what I was looking for.