claculation of difference of two date/time filed and store it another date time field

Mansi roy
Tera Contributor

Hello All,

 

I have one requirement to store the time when the state puts onhold. Then need to capture the time when the state changes from onhold to any other state. Then need to store the difference value of when incident put onhold and the time when incident changes from onhold to inprogress or reoslved.

 

Can nayone please help me how to acheive.

Three fields:

1st-Onhold start time

2nd-Onhold end time

3rd:Total time

how to acheive this one.

2 REPLIES 2

Satishkumar B
Giga Sage
Giga Sage

@Mansi roy use SLA metrics. Configure an SLA definition to track the time spent in the "On Hold" state, and then use Business Rules to update custom fields with the SLA metrics.


Hello @Satishkumar B ,

 

Thanks for your reply.

 

I have three types field.

 

Mansiroy_0-1724754941577.png

Here the total duration is not giving the correct result. I have written the below before business rule script.

 

(function executeRule(current, previous /*null when async*/) {
var startTime = current.u_onhold_duration.dateNumericValue();
var endTime = current.u_onhold_end_time.dateNumericValue();
current.u_total_duration.setDateNumericValue(endTime-startTime);
})(current, previous);
 
but it is not giving the correct result.