How to add time to duration field(alredy filled with some value). business Rule

Shaik Imran
Tera Contributor

How to add time to duration field(alredy filled with some value). business Rule

we wrote a before update business rule. this runs when the end date is changes

start time - date/time field;

end time - date/time field;

we take the difference of start time and end time.

update that difference in duration- duration field;

 

if we change the end time again , again we need to take the difference of start time and end time.

add  that difference to duration field(alredy filled with some value)

var rt = current.u_rca_review_time.dateNumericValue();
//var rt1 = GlideDateTime(rt);

var date1 = current.start_time.getDisplayValue();
var date2 = gs.nowDateTime();//end time
var gdt1 = GlideDateTime(date1);
var gdt2 = GlideDateTime(date2);
var duration = gs.dateDiff(gdt1, gdt2, false);
//var dur = new GlideDuration(duration);

var difftime = GlideDateTime(duration);
//duration1 = GlideDuration(duration);
//var answer = rt1.add(duration);
var duration1 = rt1.add(duration);

gs.log('imran1' + '-' + duration + '-' + dur);
current.duration = duration1;

we tried a lot but it is not working. 

when the duration field is empty it is working,

duration field alredy with some value it is not working

 

 

 

 

 

0 REPLIES 0