How to get first 10 Active records in incident table
This content was last updated in 2024. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 05:31 AM
Hi am new to ServiceNow please help to code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 05:35 AM
Hi Harsha,
please check this
var gr=newGlideRecord('incident');
gr.addQuery('active','true');
gr.setLimit('10');
gr.query();
while(gr.next()){
gs.print(number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 06:16 AM
var gr=newGlideRecord('incident');
gr.addQuery('active','true');
gr.setLimit('10');
gr.query();
while(gr.next()){
gs.print(gr.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 06:20 AM
Hi,
Use the below code to get 10 active incidents.
var gr = new GlideRecord('incident');
gr.addQuery('active','true');
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
while(gr.next())
{
gs.print(gr.number);
}
Hope it helps, please mark my response as correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2024 05:56 AM
Hi Raghu Ram Y,
I understood the script but where to execute it, such as on client script or UI Policy or business rule, script include as we want to show incidents in list view.