I want list of latest 10 incident records only ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2023 05:37 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2023 06:30 AM
Then @Dan O Connor has already given the correct answer. Please mark it as correct.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2023 06:01 AM
Hi @Abhishek Kathe ,
1. Go to incident module click on open incident.
2. Click on filter.
3. Active is true and add sort z to a . after that run the filter.
4. Go to the form header and right click and select show > 10 records per page.
Please refer the below screenshot.
Mark my answer correct and helpful if helps you.
Thanks,
Nivedita Patil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2023 06:04 AM
Hi @Abhishek Kathe with the below script you can get the list of latest 10 incident records
// Create a GlideRecord object for the Incident table
var incidentGR = new GlideRecord('incident');
// Order the records by the 'sys_created_on' field in descending order (latest first)
incidentGR.orderByDesc('sys_created_on');
// Limit the query to fetch only the first 10 records
incidentGR.setLimit(10);
// Execute the query
incidentGR.query();
// Iterate through the records
while (incidentGR.next()) {
// Access and print the fields you need from each record
var incidentNumber = incidentGR.getValue('number');
var shortDescription = incidentGR.getValue('short_description');
// Print or process the retrieved data as needed
gs.info('Incident Number: ' + incidentNumber + ', Short Description: ' + shortDescription);
}
Thanks & Regards,
Eswar Chappa
Mark my answer correct and Helpful if this helps you 😀
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2023 06:21 AM
@Abhishek Kathe
You can achieve it by with below script ways
Background script: Use the below script to get the latest 10 active records from an incident table.
var gr = new GlideRecord('incident');
gr.addQuery('active', true); // Optionally, filter by active incidents
gr.orderByDesc('sys_created_on');
gr.setLimit(10); // Limit the result to the latest 10 records
gr.query();
while (gr.next()) {
gs.info('Incident Number: ' + gr.getValue('number'));
}
Help others to find a correct solution by marking the appropriate response as the correct answer and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2023 06:22 AM - edited ‎09-18-2023 06:23 AM
Hi @Abhishek Kathe,
You can try the below code in BG script.
var gr = new GlideRecord('incident');
gr.addActiveQuery();
gr.orderByDesc('sys_created_on');//you can replace with updtated as well
gr.setLimit(10);
gr.query();
while(gr.next()){
gs.print(gr.number)
}
Please mark this answer as correct and helpful if it solves your issue.
Regards,
Siva Jyothi M.