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 06:31 AM
Hi Harsha,
Please find the code.
var grI=new GlideRecord("incident");
grI.addActiveQuery();
grI.orderByDesc("sys_created_on");
grI.setLimit(10);
grI.query();
while(grI.next())
{
gs.info(grI.getDisplayValue());
}
Mark my answer as correct or hit like based on impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 06:37 AM
hi please try this
var gr = new GlideRecord('incident');
gr.addQuery('active','true');
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
while(gr.next())
{
gs.log("The active records:"+ gr.number);}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 06:37 AM
var gr = new GlideRecord('incident');
gr.addQuery('active','true');
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
while(gr.next())
{
gs.log("The active recprds"+ :gr.number);}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-01-2023 03:45 AM - edited ‎07-07-2023 04:33 AM