- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2020 07:26 AM
Hi All,
I wanted to get last 10 records in incident table through background script.
Please help me out here.
Thanks & Regards,
sAtyA.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2021 11:26 PM
HI,
Please find the below script for getting last 10 records.
var incRecord = new GlideRecord('incident');
incRecord.orderByDesc('sys_created_on');
incRecord.setLimit(10);
incRecord.query();
while(incRecord.next()){
gs.info("Incident Record: " + incRecord.number);
}
Please mark this helpful if your query is resolved
Best Regards
Himanshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2020 07:46 AM
Hope you are doing good.
Did you get a chance to check on the solution provided to resolve your query?
If your query is resolved please my response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2021 07:20 AM
try this code
display business rule
var inc = new GlideRecord('incident');
inc.setLimit(10);
inc.orderByDesc('number');
inc.query();
while(inc.next())
{
gs.addInfoMessage("last 10 records #" + inc.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2021 11:26 PM
HI,
Please find the below script for getting last 10 records.
var incRecord = new GlideRecord('incident');
incRecord.orderByDesc('sys_created_on');
incRecord.setLimit(10);
incRecord.query();
while(incRecord.next()){
gs.info("Incident Record: " + incRecord.number);
}
Please mark this helpful if your query is resolved
Best Regards
Himanshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2021 05:43 AM
Can this also be written as an Encoded Query or UI Macro?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2021 06:45 AM
I got that to work, but how do you translate that over to a UI Macro?