Ho to calculate on hold time for an SLA attached to a task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 11:50 PM
Hi All,
I have a requirement where I need to calculate the on hold time for an SLA attached for a task. when a task is put in on hold state The SLA should not get paused and the SLA time should be calculated until the state is changed to some other state. Again if the SLA is put on hold from some other state then I need to display the Total time for which the SLA was in On hold state.
Please help me in solving this issue.
Immediate help is appreciated.
Regards,
Zabeeulla.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 12:28 AM
Hi Fogg,
I haven't worked on database view if you could help me how to combine two tables and add the field which calculates the time for on hold state and sum up the total time of on Hold state.
Please help me how would I achieve this using metrics, It would be great learning about metrics from you.
Regards,
Zabeeulla.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 02:39 AM
Check the baseline metric 'Incident state duration', it is MTRC0000004 in my instance.
This will track for each status of any given incident the duration the incident was in that state.
You can check the values in table metric_instance, for each incident you should see a record per state. The states will be in column 'value'.
If you now need the SLA measurement in the same report as the on-hold timings, you will need to join sla_task and metric_instance. The joining criteria would be like:
task_sla.<task> = metric_instance.document_id and metric_instance.definition = Incident State Duration and metric_instance.value = on hold
(very simplistic representation of the join condition )
Using this you could avoid any additional fields and business rules on your incident tables.
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 01:10 AM
Hi Zabeeulla,
You can write a client script to achieve the difference of two dates :
function onLoad() {
//Type appropriate comment here, and begin script below
//current date
var currentDateObj = new Date();
var currentDateStr = formatDate(currentDateObj, g_user_date_time_format);
var currentDateNum = getDateFromFormat(currentDateStr, g_user_date_time_format);
//get opened date
var startDateStr = g_form.getValue('opened_at');
var startDateNum = getDateFromFormat(startDateStr, g_user_date_time_format);
//get updated date
var endDateStr = g_form.getValue('sys_updated_on');
var endDateNum = getDateFromFormat(endDateStr, g_user_date_time_format);
var diff = endDateNum - startDateNum;
var diffInDays = diff/(24*60*60*1000);
alert('difference is 1 : ' + diff);
alert('difference is 2 : ' + diffInDays);
alert('difference is 3 : ' + Math.round(diffInDays*100)/100);//rounding off to two decimal places.
}
I have just checked or tested this script on my incident table. you could do this on task_sla table. But it would be good for you if you try a server side code to achieve date results.
Please let me know your further queries.
Thanks,
Arnab
Please mark Helpful/Correct according to the worthiness of my solution.