Get the oldest incident
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 05:11 PM
Hi all,
I'm trying to obtain the oldest ticket to show the age in a single score in a dashboard
This is the script that I have:
function getOldIncident (){
var glideIncident = new GlideRecord('incident');
glideIncident.addQuery('state',1);
glideIncident.orderBy('sys_created_on');
glideIncident.setLimit(1);
glideIncident.query();
var number='';
if(glideIncident.next()){
number=glideIncident.getValue('number');
}
return number;
}
and this is how I applied in the report and also the result that I obtained...
I already tried with this other script but I didnt obtain any result
function getOldIncidentTest (){
var glideIncident = new GlideRecord('incident');
glideIncident.addQuery('state',1);
glideIncident.orderBy('sys_created_on');
glideIncident.setLimit(1);
glideIncident.query();
var number='';
if(glideIncident.next()){
var incidentDate = new GlideDateTime();
incidentDate.setValue(glideIncident.sys_created_on);
var dur = new GlideDuration();
dur = GlideDateTime.subtract(incidentDate, new GlideDateTime());
}
return dur;
}
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 05:52 PM
Is the incident shown the correct or incorrect oldest incident in the New state? What are you expecting to see?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 10:08 AM
Yes I already got the oldest incident but I want to show only the age of the oldest incident in a single score to add in a dashboard.