Add and sum Business elapsed time that SLAS complete to a field on incident form

williams2
Tera Expert

Hello, I am trying to assign the Business elapsed time of the SLAs to a new field that I created called "Total SLA Business Elapsed Time" with the intention of adding up the Business elapsed time of all the SLAs in complete resolution of my incident.
Does anyone know how I can achieve this? I have tried with a Business rule but I cannot get it to assign me the elapsed time or the sum.

 

 

An example would be:
SLA 1 was completed in 1 minute and the group was changed.
SLA 2 was completed in 20 minutes and resolve for the group

What should be assigned to the Total SLA Business Elapsed Time field would be = 21 minutes.

3 REPLIES 3

Swamy Malluri
Tera Guru
Tera Guru

Hi @williams2 ,

 

Can you share your script to check why its not working. 

 

You can use GlideAggregate API to get the sum of SLAs tagged to your Incident and get the Business elapsed time and update incident.

 

Below is the sample script.

 

var agg = new GlideAggregate('task_sla');
agg.addQuery('task', current.sys_id);
agg.addQuery('sla.type', 'resolution'); 
agg.addAggregate('SUM', 'business_elapsed_time');
agg.query();
if (agg.next()) {
totalBusinessElapsedTime = parseInt(agg.getAggregate('SUM', 'business_elapsed_time'), 10);
}

current.u_total_business_elapsed_time = totalBusinessElapsedTime;

 

 

Please select Accept/Help button if my answer addresses your query.

 

Regards,

Swamy

Hi @Swamy Malluri   thanks for answer my post

Honestly, my script is very simple. I have it in a business rule towards the "task_sla" table that is executed after insert or update.
The only problem is that it is only assigning me the SLA Response time and I need it to assign me the SLA Resolution time and once there is a group change and a new SLA Resolution is generated, it will add up the SLA Resolution times.

Until the incident is closed, now it will add up all the SLA Resolution times.



var businessElapsedTime = current.business_duration.getDisplayValue();
    var incident = new GlideRecord('incident');
    if (incident.get(current.task)) {
        incident.u_total_sla_business_elapsed_time = businessElapsedTime;
        incident.update();
    }

Hi @williams2 ,

Could you please elaborate your issue ? Do you want to consider resolution time only to update in Incident's total business elapse time ? or response SLA as well ?

What is output from your above script ? 

 

Thanks & Regards,

Swamy