Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 04:53 PM
- 31,846 Views
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 05:30 PM
Please note that the setLimit(1) will limit the query to only the first record returned by the query and the orderByDesc('sys_created_on') will sort the results based on its created date been the most recent one the first one in the list.
I hope this helps
Thanks,
Berny
10 REPLIES 10

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2022 01:01 AM
Hi Hari,
We can use setLimit(10) to get latest 10 records.
var gr=new GlideRecord('incident');
gr.orderByDesc('sys_created_on');
gr.setLimit(1);
gr.query();
while(gr.next()){
gs.info(gr.number);
}