Can we limit report to show only limited records, lets say 10?

Jithender123
Tera Contributor

Hello Community,

 

I have a requirement to show only top 10 oldest incidents on the report.

the report should limit only to 10.

 

Please assist.

1 ACCEPTED SOLUTION

J Siva
Tera Sage

Hi @Jithender123 
There's no direct approach to acheive this on the basic reporting.
However, you can using scripting to achieve this. PFB sample.

1. Script Include: Client callable

JSiva_0-1745411663361.png

var getOldIncidents = Class.create();
getOldIncidents.prototype = {
    initialize: function() {},
    getIncs: function() {
        var arr = '';
        var incidentGR = new GlideRecord('incident');
        incidentGR.addActiveQuery(); // optional: to get only active incidents
        incidentGR.orderBy('sys_created_on'); // order by creation date 
        incidentGR.setLimit(10); // limit to 10 records
        incidentGR.query();
        while (incidentGR.next()) {
            arr += incidentGR.sys_id + ',';

        }
        return arr;
    },
    type: 'getOldIncidents'
};

2. Report: Call script include form the report filter.

JSiva_1-1745411753262.png

javascript:new getOldIncidents().getIncs();

 

Regards,
Siva

View solution in original post

2 REPLIES 2

J Siva
Tera Sage

Hi @Jithender123 
There's no direct approach to acheive this on the basic reporting.
However, you can using scripting to achieve this. PFB sample.

1. Script Include: Client callable

JSiva_0-1745411663361.png

var getOldIncidents = Class.create();
getOldIncidents.prototype = {
    initialize: function() {},
    getIncs: function() {
        var arr = '';
        var incidentGR = new GlideRecord('incident');
        incidentGR.addActiveQuery(); // optional: to get only active incidents
        incidentGR.orderBy('sys_created_on'); // order by creation date 
        incidentGR.setLimit(10); // limit to 10 records
        incidentGR.query();
        while (incidentGR.next()) {
            arr += incidentGR.sys_id + ',';

        }
        return arr;
    },
    type: 'getOldIncidents'
};

2. Report: Call script include form the report filter.

JSiva_1-1745411753262.png

javascript:new getOldIncidents().getIncs();

 

Regards,
Siva

Ankur Bawiskar
Tera Patron
Tera Patron

@Jithender123 

you can check the approach shared by @J Siva which has scripting involved

If my response helped please mark it correct and close the thread so that it benefits future readers.

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