It seems gantt.getTotalSlack(task) and gantt.getFreeSlack(task) are alwayse using Gantt default/global calendar to calculate the slacks.
Gantt Default/global calendar is a 24 hours calendar
The task is assigned with dayshift calendar(8 hours a day from 9am to 5pm) and the task end datetime is 5pm of 5th of March
The project end date time is 5pm of 6th of March
In this case, I think the correct total/free slack should be 8/8 hours, but gantt.getTotalSlack(task) and gantt.getFreeSlack(task) would give the result of 24/24 hours as its using project default/global calendar to do the calculation instead of use task assigned calendar(day shift calendar).
So wonderng if anyone know a easy wrok around or if the fix is in next release.
If you don’t enable the work_time parameter, it is expected that the critical path doesn’t use the work time settings.
You need to enable the work_time parameter and set the calendar_id: "fulltime" parameter for the tasks that you want to use the 24-hour calendar.
Also, the critical path calculation is usually working with auto-scheduling. And in that case, Gantt auto-schedules tasks even if they have different calendars.
If auto-scheduling is turned off, the free and total slacks should not take successors into account as they cannot move them to the future date. Successors can be affected only when auto-scheduling is enabled.
if you look at ‘Task #3’, gantt.getFreeSlack(targetTask) and gantt.getTotalSlack(targetTask) shows the free/total slack are 5/5, but becasue I have assigned fulltime calendar to ‘Task #3’, are they should be 17/17 hours?
Maybe I have misunderstood how gantt total and free slack works, but I think in MsProject, it will calculate the free and total slack based on task assigned calendar, but it seems in the sinppet, it still using the gantt default calendar.
Thank you for the clarification and sharing the snippet. Yes, that seems to be a bug in Gantt. If the tasks Project #1 and Task #3 are linked, Gantt calculates the slack correctly. But when Task #3 doesn’t have successors, Gantt uses the global calendar to define the slack.