Print 10 latest active incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 01:55 AM
Print 10 latest active incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 08:59 AM
Hi @trtrtrtrtrtrtrt ,
Please refer the below link.
Mark my answer as accepted solution and helpful if helps you.
Thanks,
Nivedita Patil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 09:03 AM
@trtrtrtrtrtrtrt ,Please use below Script
var incRecord = new GlideRecord('incident');
incRecord.orderByDesc('sys_created_on');
incRecord.setLimit(10);
incRecord.query();
while(incRecord.next()){
gs.info("Incident Record: " + incRecord.number);
}
Regards,
Shyamkumar
Regards,
Shyamkumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 10:00 AM
@trtrtrtrtrtrtrt Here is the script for you.
var list = new GlideRecord("incident");
list.addActiveQuery();//Get only active records
list.orderByDesc('sys_created_on');//order by created date (used Desc to show latest first);
list.setLimit(10); //Limit the records to 10
list.query();
while (list.next()){
gs.info(list.getValue('number'));//Prints incident number
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 11:00 AM
Hello @trtrtrtrtrtrtrt ,
Please use the code below.
var grINC = new GlideRecord('incident');
grINC.addActiveQuery(); // Get only active records
grINC.orderByDesc('sys_created_on'); // Order by created date (latest first)
grINC.setLimit(10); // Limit the records to 10
grINC.query();
while (grINC.next()) {
gs.info("Incident Record: " + grINC.number);
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket