Using Background script How to get the top 5 close incident records in this year?

Arvind Kumar1
Tera Contributor

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?

5 REPLIES 5

4b0d3
Giga Guru

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?..