i want to get first 10 incidents list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
How can i retrieve the top 10 incident records from the incident table using JS/Glide Record?
For Example, i want to retrieve the 10 most recently created incidents.
Could someone please provide an example script.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Swathi504893573 ,
var inc = new GlideRecord('incident');
inc.orderByDesc('sys_created_on');
inc.setLimit(10);
inc.query();
while (inc.next())
{
gs.info('Incident Number: ' + inc.number + ' | Created: ' + inc.sys_created_on);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
hi @Swathi504893573 ,
You can use orderByDesc() with setLimit(10).
Example:
var gr = new GlideRecord('incident');
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
while (gr.next()) {
gs.info(gr.getValue('number') + ' - ' + gr.getValue('sys_created_on'));
}
This will return the 10 most recently created incidents.
If this helps, please mark it as Helpful and accept the solution.
Regards,
Tejas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Swathi504893573 ,
You can refer this :
If this helps you then mark it as helpful and accept as solution.
Regards,
Aditya
var gr=new GlideRecord('incident');
gr.setLimit(10);
gr.orderByDesc('sys_created_on');
gr.query();
while(gr.next())
{
gs.print('Number :'+gr.number)
}
