How to set the number of records in the Report in the dashboard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 10:08 PM
I have requirement where I have created the Dashboard. In that dashboard I have added the report through widget. The Report shows the list of total numberof records in the table. I need to show only the 1st 10 records in that report. How should I configure this.
Attaching the current dashboard for reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 02:21 AM
Hi @Chaitanya ILCR ,
I can see some changes when I made the sandbox enabled to true. Earlier in Sysid it was showing as null, but now it is giving some value but still the list is not visible
Attaching the updated screenshots
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 11:01 PM - edited 05-19-2025 11:22 PM
Hi @SanikaK ,
it should work
did you set the correct table in the report? (is it sn_cim_register?)
update the script include's caller access and accessible from and sandbox enabled
and the filter to include scopename(sn_cim.RecordFetcher2)
javascript:new sn_cim.RecordFetcher2().getTop10SysIds()
if you are not able update it
create a new script include
name:RecordFetcher2
snadbox enabled: true
accessible from : all application scopes
caller access:caller tracking
var RecordFetcher2 = Class.create();
RecordFetcher2.prototype = {
initialize: function() {},
getTop10SysIds: function() {
var result = [];
var gr = new GlideRecord('sn_cim_register'); //update your table name looking at screenshot looks like those are continual improvement records
// gr.addEncodedQuery('addYOurEncodeQuery here'); //add encoded query here
gr.setLimit(10);
// gr.orderByDesc('sys_created_on') use orderBy if need I'm commenting this
gr.query();
while (gr.next()) {
result.push(gr.getValue('sys_id'));
}
return result.join();
},
type: 'RecordFetcher2'
};
filter sys id IS ONE OF javascript:new sn_cim.RecordFetcher2().getTop10SysIds() in case of old one remove 2 from RecordFetcher2
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 02:40 AM
Yes in the report I want to list only the latest 10 reocrds. Currently, in the table total number of records in 46.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 02:49 AM
please create classless script include like this and see
Then call in report filter condition like this
SysId [IS ONE OF] javascript: latestRecords();
function latestRecords() {
try {
var arr = [];
// your GlideRecord and iterate and then push sysId in array
var gr = new GlideRecord("tableName");
gr.orderByDesc("sys_created_on");
gr.addQuery("name", "value");
gr.query();
while (gr.next()) {
arr.push(gr.getUniqueValue());
}
return arr.toString();
} catch (ex) {
gs.info(ex);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader