Clear leveling#
Remove the delays and splits that level wrote into a project, so every task goes back to its unleveled dates.
Leveling stores its result in two task fields: levelingDelay and pauses. To clear leveling, set levelingDelay to 0 and pauses to an empty list on every task that has either, then reschedule. For how leveling sets these fields, see Leveling resources.
Prerequisites#
- A solved
Projectthat carries leveling, either from alevelcall or from loaded data with a non-zerolevelingDelayor non-emptypauses. - The ids of the tasks that carry a delay or pauses. Take them from your own model, or from
schedule.updatesof theLevelingResult.
Steps#
-
Build one
TaskUpdateper leveled task. SetlevelingDelaytoPatch.of(0.0)andpausestoPatch.of(new Vec<Pause>()), and put all the updates into oneSchedulingChanges:static SchedulingChangesDon't put dates in the update. When the update has no date, the
levelingDelaychange moves the stored start back by the delay. Thepauseschange keeps the start and duration and recomputes the end. -
Apply the changes with
applyand check theApplyReport:var report ; if -
Reschedule with
solve(null, …)and writeresult.updatesback to your model:var result ;The cleared dates become the accepted baseline. The resource contention that leveling resolved shows up again in
result.overallocations.
The full example below levels three 2-day tasks that share dev1, then clears the leveling. It uses the default calendar (Monday to Friday, 08:00-12:00 and 13:00-17:00) and starts on Monday, August 10, 2026:
;
;
;
Re-level from scratch instead#
To replace old leveling with a fresh run, skip the steps above and call level again. LevelingOptions.clearFirst is true by default. The run first sets levelingDelay to 0 and pauses to an empty list on every in-scope task that has either, then levels the clean plan:
var result ;
result.schedule.updates is a diff against the state the call started from. A task whose old delay was cleared and not replaced still gets an update entry, so writing the updates back keeps your model in sync.
With a scope, the run clears only in-scope tasks. Set clearFirst to false to keep the existing delays and pauses and level on top of them.
Things to know#
Patch.nullValue()also works. OnlevelingDelayit restores the default of 0, and onpausesit clears the list. Don't usePatch.of(null)onpauses: it throwsNullPointerExceptionwhen applied.- Only leveling produces pauses. Every pause counts as leveling-owned, whether or not its
byis set, so clearing removes all of them. - To see what clearing would do before you commit it, pass the same changes to
preview. The project stays untouched. See Previewing changes. - In a live editor, set
changes.baselineIdto the baseline your model shows.applythen throwsProjectExceptionwith codeProjectError.STALE_BASELINEif the project has moved on. See Error handling. - If
applyrejects an operation,report.needsResyncistrue, andsolve(null, …)throwsProjectError.NEEDS_RESYNCuntil you send the full data withsolve(data, …). See Recover from rejected changes.
Result#
The example prints B and C back on Monday, and the overallocation window on dev1 returns:
B: 2026-08-10 08:00 .. 2026-08-12 08:00
C: 2026-08-10 08:00 .. 2026-08-12 08:00
dev1: 2026-08-10 08:00 .. 2026-08-11 17:00, peak 3.0