How to do the sum of pause time for all tasks in a RITM ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2023 05:13 AM
Hello All,
I need to have the sum of pause time for all tasks of a RITM.
For the moment, I have this run script below on my workflow which permit me to retrieve the pending time for the first task.
I have several tasks and I don't know how to script the rest so that the loop continues until the end of the tasks.
Could you help me please?
var pauseDuration;
var task_sys_id;
var duration_result;
var get_tasks_sysid = new GlideRecord('sc_task');
get_tasks_sysid.addQuery('request_item', current.sys_id.toString());
get_tasks_sysid.query();
while (get_tasks_sysid.next()) {
task_sys_id = get_tasks_sysid.sys_id.toString();
var slaCheck = new GlideRecord('task_sla');
slaCheck.addQuery('task', task_sys_id);
slaCheck.query();
while (slaCheck.next()) {
pauseDuration = (new GlideDateTime(slaCheck.pause_duration.toString()).getNumericValue()) / 1000;
duration_result = parseInt((pauseDuration), 10);
}
var hours = Math.floor(duration_result / 3600);
var minutes = Math.floor((duration_result - (hours * 3600)) / 60);
var seconds = duration_result - (hours * 3600) - (minutes * 60);
// Display formating for hours
if (hours < 10) {
if (hours == 0) {
hours = "00";
} else {
hours = "0" + hours;
}
}
// Display formating for minutes
if (minutes < 10) {
if (minutes == 0) {
minutes = "00";
} else {
minutes = "0" + minutes;
}
}
// Display formating for seconds
if (seconds < 10) {
if (seconds == 0) {
seconds = "00";
} else {
seconds = "0" + seconds;
}
}
}
current.variables.toto = hours + ':' + minutes + ':' + seconds;
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 09:03 AM
Hello Chetan,
This line
if (!(slaCheck.pause_duration.nil()) || !(slaCheck.pause_duration=='NaN))
is not accepted on my runscript.
Error message :
Do you have an idea ?
Thank you.