- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 04:53 PM
- 31,841 Views
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 05:23 PM
Hi Neha, you mean by the last created record on the table?
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 05:24 PM
If so you can do a GlideRecord and do a orderByDesc on the field sys_created_on
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 05:27 PM
Here goes an example:
var gr = new GlideRecord ('incident');
gr.orderByDesc('sys_created_on');
gr.setLimit(1);
gr.query();
if (gr.next()){
gs.print (gr.number + ' - ' + gr.sys_created_on);
}
- 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