what is the signance of set limit function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 09:49 PM
what is the signance of set limit function

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 09:59 PM
limit [setLimit()] function helps to get how many records you want to retrieve in the GlideRecord(). http://wiki.servicenow.com/index.php?title=GlideRecord#setLimit
if you want to get the top 10 latest created record from a table then you can give setLimit(10) in the GlideRecord().
Let us know if you are looking anything specific.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 10:10 PM
after execution of query . you can limit the number of records that your query will return.
eg:
if you will query of incident table to check how many active incident is available then you can simply write glide record then it will return you list of incidents number now you only want to 10 records rather than all incidents then in such scenario you will use setLimit();
var abc= new GlideRecord('incident');
abc.addActiveQuery();
abc.query();
while(abc.next())
{
gs.print(abc.number);
}
var abc= new GlideRecord('incident');
abc.addActiveQuery();
abc.setLimit(10);
abc.query();
while(abc.next())
{
gs.print(abc.number);
}
hope it will help you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 03:22 AM
That was very clear and although I didn't ask this I have been looking around for such an example fo this question. Thank You!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 03:56 AM
glad it helped you