calendar_duration not populating on the work order tasks

Aishwarya Pati1
Tera Contributor

Hi! I am unable to populate the calendar_duration (Actual duration field) on the work order task which normally calculates a duration from the actual work start/end time. This is OOTB.

 

I can see that the calculation uses SMDateValidation: 

// set the actual duration based on actual start and end times
if (!task.work_start.nil() && !task.work_end.nil()) {
var start = new GlideDateTime(task.work_start.getGlideObject());
var end = new GlideDateTime(task.work_end.getGlideObject());
var difference = gs.dateDiff(start.getDisplayValue(), end.getDisplayValue(), false);
if (start.getNumericValue() < end.getNumericValue()) {
task.calendar_duration = difference.toString();
}
} else if ((task.work_start.nil() || task.work_end.nil()) && !task.isNewRecord())
task.calendar_duration = "";
},
 
 
Can you please let me know why the calendar_duration (Actual duration field) would not be populating on the work order tasks?
 
2 REPLIES 2

Mark Manders
Tera Patron

Do you have the other fields filled? Do you have a start and end date on the form?

Use logs in the script to see the actual values you get.

Yes I do. Other fields have values. 

 

Also, could you please let me know if there is a specific way the actual duration get populated, example, when the task is closed, etc.