Load all task dates#
Get the start, end and duration of every scheduled task from one solve, for example to fill your UI when a project first opens.
By default, updates in a ScheduleResult is sparse: it lists only the tasks that moved. Set includeUnchanged: true in the solve options and the same solve also reports the tasks that didn't move. You don't need a separate call.
Steps#
-
Serialize the solve options with
includeUnchangedset totrue:const = ; -
Pass the options to the call that loads the data. Use
solvewith a data string for a long-livedJsonProject, orschedulefor a one-shot job:const = ; // or, without a handle: schedule(JSON.stringify(data), options) const = ; -
Check
ok, then read every entry ofresult.updates. Each entry hasstart_date,end_dateanddurationset.
The full example below schedules three tasks. review doesn't move, but it's still reported:
const = ;
const = ;
const = ;
const = new;
Each entry of updates looks like this:
Get the full list from an already solved project#
To reload every date later, call solve without data and with the same options. On a solved project with no pending edits, the call doesn't replan or change the accepted state, and baselineId stays the same:
const = ;
Switch back to sparse results for the edits that follow. "{}" returns only what changed:
const = ;
The result cache uses the whole options object as its key. An includeUnchanged call never gets a cached sparse result, and a sparse call never gets a cached full one.
What is and isn't reported#
- The result includes every scheduled task: leaf tasks, summaries and milestones. Check each entry's
kind("task","summary"or"milestone") to tell them apart. - Tasks with
unscheduled: trueare never reported. leveling_delayandpausesnever appear, because a solve doesn't change them.baselineIdfollows real changes only. Asking for unchanged tasks doesn't create a new baseline.- With
subtree, the result holds every task in the subtree, including the subtree tasks' ancestors. Tasks outside the subtree appear only when a sparse subtree solve would report them too, because they changed or were edited. - On a project with a dependency cycle, nothing is scheduled. The result still lists every scheduled task, in model order, with its dates and duration as stored.
subtreeis ignored, and no entry has areason, even withreasons: true. previewandlevelalways return sparse updates.PreviewOptionshas noincludeUnchangedfield.
Result#
Run the example with node. It prints one line per task, including review, which didn't move:
design 2026-01-01 00:00..2026-01-03 00:00 2
build 2026-01-03 00:00..2026-01-04 00:00 1
review 2026-01-05 00:00..2026-01-06 00:00 1
Without includeUnchanged, the same solve reports only build.
See Reading results for how to write the dates back into your model.