- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 02:37 PM
I am trying to do a get call to retrieve the latest 10 records in a incident table.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 09:31 PM
Hi Tom,
setLimit(): Sets the limit for how many records you want to fetch.
var c=0;
var check= new GlideRecord('incident');
check.addQuery('category','software');
check.setLimit(10);
check.query();
while(check.next())
{
c++
gs.print('check the :'+check.number);
}
gs.print('total nnumber of record is:'+c);
OUTPUT
http://wiki.servicenow.com/index.php?title=GlideRecord#setLimit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 04:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2017 01:14 AM
Hi Shishir,
yes, i have modified the code and it gives result as number by descending order.
Output:
Code:
var c=0;
var gr= new GlideRecord('incident');
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
while(gr.next())
{
c++
gs.print('check the :'+gr.number);
}
gs.print('total number of record is:'+c);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2022 09:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2024 02:29 AM
Can any one let me know what change should be done to print last 10 records of the current logged in user .