how to get the last 10 records in incident table?

SN27
Giga Expert

Hi All,

I wanted to get last 10 records in incident table through background script.

Please help me out here.

Thanks & Regards,

sAtyA.

1 ACCEPTED SOLUTION

Himanshu Gupta1
Mega Guru

HI,

Please find the below script for getting last 10 records.

var incRecord = new GlideRecord('incident');
incRecord.orderByDesc('sys_created_on');
incRecord.setLimit(10);
incRecord.query();
while(incRecord.next()){
gs.info("Incident Record: " + incRecord.number);

}

 

Please mark this helpful if your query is resolved

Best Regards

Himanshu 

View solution in original post

10 REPLIES 10

Priya_Sri
Tera Contributor

var gr = new GlideRecord('incident');
gr.orderBy('sys_created_on');
gr.setLimit(10);
gr.query();
while(gr.next()){
gs.info("Incident Record: " + gr.number);

}