The CreatorCon Call for Content is officially open! Get started here.

Business rule to calculate duration runs perfectly for Planned duration but won't run at all for Actual duration.

tkh
Kilo Expert

In our change module we have date/time fields for planned start and end date and times, and date/time fields for actual start and end date and times.  We got a request to a duration fields and have the planned duration and the actual duration of the changes be calculated based on the start and end times.  So we added duration field for the Planned duration, and for the Actual duration.

Now the only difference in any of this is that the users enter the planned start and end date/times, and the system will populate the Actual start date/times based on when the users click on the Start Change and Work Completed buttons allowing the system to capture the actual exact date and time the change was placed in progress and when it move to the Review state.  Other then that everything is EXACTLY the same.

So I created a business rule that calculated the duration between the start and end dates (see below for the script) and it worked perfectly for the Planned Duration.  However when I used the exact same script and calculation for the actual duration it doesn't work, nothing gets populated.  Even trying different methods, nothing works, and I am not seeing why nothing seems to work.  So looking for some help and fresh eyes, or advice if anyone has run into this before.  I just know I am missing something I should be seeing here, but been looking at it too long.

SCRIPT

Before on Update

//get difference between start date and end date as time value
var diff = gs.dateDiff(current.work_start.getDisplayValue(), current.work_end.getDisplayValue(), false);
//set the planned duration field with the time value of the diff variable above
//then set it to the display value so it shows properly
current.u_act_duration = diff;
current.u_act_duration.setDisplayValue(diff);

 

3 REPLIES 3

ncp
Mega Guru

What does log statements on these give you? Are they providing the right values? What kind of field is u_act_duration?

tkh
Kilo Expert

I am not finding anything in the logs, and the field is a duration field just like the one for Planned duration.

 

find_real_file.png

ncp
Mega Guru

Are you saying you have gs.info statements in your script and they dont give you anything or you dont have those? If you have not added those can you log statements so that you can see exactly what each step is doing?