Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2018 05:50 AM
I have below background script, I want to get the record which is most recently updated and display
var inc=new GlideRecord('incident');
inc.query()
while(inc.next())
{
var updated=inc.sys_updated_on;
var inc1=new GlideRecord('incident');
inc1.query()
while(inc1.next())
{
var updated1=inc.sys_updated_on;
if(updated1>updated)
{
var updated3=updated1;
}
}
gs.print(updated3);
}
}
Solved! Go to Solution.
Labels:
- Labels:
-
Scripting and Coding
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2018 06:00 AM
Here you go:
var inc=new GlideRecord('incident');
inc.orderByDesc('sys_updated_on');
inc.setLimit(1);
inc.query();
while(inc.next()) {
gs.info(inc.getDisplayValue());
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2018 06:00 AM
Here you go:
var inc=new GlideRecord('incident');
inc.orderByDesc('sys_updated_on');
inc.setLimit(1);
inc.query();
while(inc.next()) {
gs.info(inc.getDisplayValue());
}