Calculate business duration based on start date & end date field.

Mabubi
Tera Contributor
 
calculate business duration based on start & end date fields.Start date value will set once state changes to work in progress *& end date will set once state move to close complete.This scenario which Business rule will use.
i have used after business rule. But  can't use current.update() right.so i have writter aync also its not setting the business duration.
 
Script:
(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    gs.info("check br duration");
    var start = new GlideDateTime(current.work_start.getDisplayValue());
var end = new GlideDateTime(current.work_end.getDisplayValue());
var duration = GlideDateTime.subtract(start, end);
current.business_duration = duration;
//current.update();
gs.info("business_duration"+current.business_duration);

})(current, previous);
0 REPLIES 0