Split assignment work#
Hand one task's work to several people, for example one developer for the first two days and another for the rest, without changing the task's dates.
The offset and duration fields of AssignmentData do this. Each assignment books only its own part of the task, called a slice. For how slices affect load, see Resources and assignments.
Steps#
-
Book each person on their part of the task. Both fields are
Doubleand count worked time from the task start, in the task'sdurationUnit:offset: where the slice starts.nullmeans the task start.duration: how much work the slice books.nullmeans up to the task end.
// Anna works the first 2 days of `build`. var anna ; // Ben starts after 2 days of work and finishes the task. var ben ; -
Pass the assignments to
solve(data, options)as usual. Then check the booked load withProject#loadProfile:var query ; query.basis ; LoadProfile profile ; -
To move the handover in a live project, send an
AssignmentUpdatefor each slice, then callsolve(null, options):var changes ; changes.assignments.update.; changes.assignments.update.; -
To book the whole task again, set the field to
Patch.nullValue(). A clearedoffsetgoes back to the task start. A cleareddurationruns up to the task end.
The full example splits the 4-day build task between Anna and Ben, prints their daily load, then moves the handover one day later:
;
;
;
loadProfile needs a solved project, so call solve(null, options) after apply and before you read the load again.
Things to check#
- Slices never move tasks. A slice edit leaves every task date as it was, but it changes the
baselineId. ASchedulingChangesthat still carries the old token fails with aProjectExceptionwhosecodeisSTALE_BASELINE. - The engine clips the slice to the task's work when it books load. A slice that runs past the task end books only up to the end. An
offsetat or past the task's duration books nothing. If the task gets shorter later, the slice follows it. - Non-working time and leveling pauses don't count as worked time. A pause or a
levelingDelaymoves the slice together with the work. - Two slices of the same resource on the same task add up where they overlap.
- Strict validation rejects an
offsetbelow0or not finite, and adurationof0or less or not finite.solve(data, options)throws anInputExceptionwithpathset toassignments[i].offsetorassignments[i].duration. Inapply, the same values show up as rejected operations inApplyReport.rejected, at paths likeassignments.update[0]. See Recover from rejected changes. - With
Validation.REPAIR, the engine clears an invalid value and adds aNote.Repaired, so the assignment books the whole task. See Accept messy input. - An assignment on an unscheduled task keeps its slice and books it again when the task is scheduled.
Result#
The example prints each person's load for Monday to Friday, before and after the handover moves:
handover after day 2
anna: [1.0, 1.0, 0.0, 0.0, 0.0]
ben: [0.0, 0.0, 1.0, 1.0, 0.0]
handover after day 3, moved tasks: 0
anna: [1.0, 1.0, 1.0, 0.0, 0.0]
ben: [0.0, 0.0, 0.0, 1.0, 0.0]
The load moves from Ben to Anna on Wednesday. build keeps its dates, so solve(null, options) reports no moved tasks.