- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016 10:14 PM
calculatedura();
function calculatedura() {
var taskRec = new GlideRecord('task');
taskRec.addQuery('state', '=', 6);
taskRec.addQuery('state', '=', 7);
var orCondition = taskRec.addQuery('sys_class_name', 'incident');
orCondition.addOrCondition('sys_class_name', 'u_request');
taskRec.query();
while (taskRec.next()) {
var ageInt = gs.dateDiff(taskRec.u_created_at.getDisplayValue(), taskRec.u_resolved.getDisplayValue(), true);
taskRec.calendar_duration = ageInt;
taskRec.update();
}
}
Solved! Go to Solution.
- Labels:
-
Dashboard
-
Performance Analytics
-
Reporting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2016 01:39 PM
Here you go. You need to pass the third parameter as false in gs.dateDiff() function.
calculatedura();
function calculatedura() {
var taskRec = new GlideRecord('task');
taskRec.addQuery('state', '=', 6);
taskRec.addQuery('state', '=', 7);
var orCondition = taskRec.addQuery('sys_class_name', 'incident');
orCondition.addOrCondition('sys_class_name', 'u_request');
taskRec.query();
while (taskRec.next()) {
var ageInt = gs.dateDiff(taskRec.u_created_at.getDisplayValue(), taskRec.u_resolved.getDisplayValue(), false);
taskRec.calendar_duration = ageInt;
taskRec.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2016 08:51 PM
Thanks a ton, It was such a small thing and causing a big issues.
Thanks a lot mate
Cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2017 03:06 PM
Now when this script is scheduled, it updated most of the records, but few are not updated. I tried to find out the difference btwn the tickets that got updated and not updated, but no luck. Tried running the script again but its not updating the tickets. Can you please suggest what could be the reason?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2017 08:14 PM
Now when this script is scheduled, it updated most of the records, but few are not updated. I tried to find out the difference btwn the tickets that got updated and not updated, but no luck. Tried running the script again but its not updating the tickets. Can you please suggest what could be the reason?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2017 03:14 PM
Now when this script is scheduled, it updated most of the records, but few are not updated. I tried to find out the difference btwn the tickets that got updated and not updated, but no luck. Tried running the script again but its not updating the tickets. Can you please suggest what could be the reason?