Using Background script How to get the top 5 close incident records in this year?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2022 10:10 PM
Dear all,
Scenario-1:-How to get the top 5 close incident records in this year?
var gr = new GlideRecord('incident');
gr.orderBy('number');
gr.setLimit(5);
gr.query();
while(gr.next())
{
gs.print(gr.number);
}
I had written this script. output was showing but not showing close incident.
Can anyone write correct script?
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2023 08:51 PM
You could also set it up in the list view of incident. Then copy the query and use it as an Encoded Query, adding the limit in the background script. What exactly does "the top 5 close incident records in this year?" mean though. The top 5 of what condition. I mean what field value are you valuing to be the "top"? Completed time? Duration? Priority?..