- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2020 05:00 AM
Hi All,
I have a query to get the resolved incidents older then 90 days but the limit is only 2500 (setLiimit) and order by resolved time.
How can I get the oldest and the latest reolved time in these 2500 records fetched as per the query.
Thanks,
Uma
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2020 05:09 AM
Hi,
sample script below
var oldestNumber = '';
var latestNumber = '';
var query = '';
var count = 1;
var inc = new GlideRecord('incident');
inc.orderBy('resolved_at');
inc.addEncodedQuery(query);
inc.query();
var totalCount = inc.getRowCount();
while(inc.next()){
if(count == 1){
oldestNumber = inc.number;
}
count ++;
if(count == totalCount){
latestNumber= inc.number;
}
}
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
‎10-15-2020 05:09 AM
Hi,
sample script below
var oldestNumber = '';
var latestNumber = '';
var query = '';
var count = 1;
var inc = new GlideRecord('incident');
inc.orderBy('resolved_at');
inc.addEncodedQuery(query);
inc.query();
var totalCount = inc.getRowCount();
while(inc.next()){
if(count == 1){
oldestNumber = inc.number;
}
count ++;
if(count == totalCount){
latestNumber= inc.number;
}
}
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
‎10-15-2020 05:18 PM
Thank you Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2020 07:51 PM
You are welcome
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
‎10-15-2020 05:25 AM
Hi
In your result set, are you getting the sys_created_on also? If yes, let me know and then we can order them again from the result set.