TaskData#
One task, summary or milestone as a plain object. Put tasks in ProjectData.tasks to load a plan, or in SchedulingChanges.tasks.add to add them to a live project. No call returns TaskData: scheduled dates come back as update entries in ScheduleResult.
Fields#
| Field | Type | Default | Description |
|---|---|---|---|
id |
Id |
required | Task id, unique among the project's tasks. |
parent |
Id | null |
no parent | Id of the parent task. "" or a value equal to SchedulingConfig.root_id also means a top-level task. |
type |
"task" | "summary" | "project" | "milestone" |
"task" |
Plain task, summary or milestone. "project" is an alias of "summary". Decides which date fields are needed, see Dates by task type. |
start_date |
DateValue | null |
none | Start of the task. |
end_date |
DateValue | null |
none | End of the task. Must not be before start_date. |
duration |
number | null |
none | Working time in duration_unit. Finite and >= 0. |
duration_unit |
TimeUnit | null |
config.duration_unit |
Unit of duration, leveling_delay and pauses. |
constraint_type |
ConstraintType | null |
none | Date constraint: "asap", "alap", "snet", "snlt", "fnet", "fnlt", "mso" or "mfo". Takes effect only when config.apply_constraints is true. |
constraint_date |
DateValue | null |
none | Date of the constraint. Required for every constraint_type except "asap" and "alap". |
auto_scheduling |
boolean | null |
true |
false fixes the task: the scheduler never moves it. |
unscheduled |
boolean | null |
false |
true leaves the task and all its descendants out of scheduling and out of results. Such tasks need no dates. |
progress |
number | null |
0 |
Completed share, from 0 to 1. With config.use_progress, 1 marks the task completed and fixed. |
priority |
number | null |
500 |
Leveling priority, an integer from 0 to 1000. Read only by Project#level. |
leveling_delay |
number | null |
0 |
Elapsed time added before the task's driven start, in duration_unit (a day is 24 hours). Finite and >= 0. Written by Project#level. |
pauses |
Pause[] | null |
[] |
Splits in the task's work, sorted by at and non-overlapping. Written by Project#level. Ignored on summaries, milestones and unscheduled tasks. |
calendar_id |
Id | null |
none | Id of the task's working calendar: an entry of ProjectData.calendars, or "global". Without it the task uses the "global" calendar, or its nearest ancestor's calendar when config.calendar_mode is "task-inherited". |
null on any optional field reads the same as leaving the field out. Unknown fields are ignored, so task objects from a Gantt UI can be passed as they are. Date fields take a string or a local Date; see DateValue.
Dates by task type#
start_date, end_date and duration are read differently for each type. Unscheduled tasks skip these rules.
type |
Accepted input | Result |
|---|---|---|
"task" |
start_date + duration |
End computed forward on the task's calendar, around any pauses. |
"task" |
end_date + duration |
Start computed backward from the end. |
"task" |
start_date + end_date |
duration is the working time between the dates. |
"task" |
all three | Accepted only when start_date + duration lands on end_date. |
"summary" |
start_date + end_date |
The given span. duration is ignored. |
"summary" |
neither date | Span taken from the dated children. |
"milestone" |
start_date or end_date |
A zero-length task at that date. duration is ignored. |
A summary with only one of the two dates is an error, and so is a plain task with fewer than two of the three fields.
Errors#
With the default validation: "strict" (see Project), an invalid task makes Project#solve, Project#analyze and schedule throw an InputError with kind: "validation" at a path under tasks[i]:
path |
When it occurs |
|---|---|
tasks[i].progress |
progress isn't finite or is outside 0..1 |
tasks[i].leveling_delay |
leveling_delay isn't finite or is negative |
tasks[i].duration |
duration isn't finite or is negative; or all three date fields are set and disagree |
tasks[i].constraint_date |
a dated constraint_type has no constraint_date |
tasks[i].pauses[j] |
pause j has a negative or non-finite at, a non-finite or non-positive length, or is out of order or overlaps the previous one |
tasks[i].calendar_id |
calendar_id names no calendar in ProjectData.calendars and isn't "global" |
tasks[i].start_date |
a plain task has fewer than two of start_date, end_date, duration; a summary has only one date; a milestone has no date |
tasks[i].end_date |
end_date is before start_date |
tasks[i] |
a summary has no dates and no dated children |
A priority that isn't a whole number from 0 to 1000 throws an InputError with kind: "validation" and path: null. Rules across tasks (unique ids, known parent, no hierarchy cycle) are on ProjectData. validation: "repair" fixes several of these cases instead of throwing.
Used by#
Project#solve,Project#analyze,schedule: throughProjectData.tasksProject#apply,Project#preview: throughSchedulingChanges.tasks.add
Example#
A summary with two dated children, a constrained task and a milestone:
const = ;
Related#
ProjectData- the plan that carriestasksTaskUpdate- editing an existing taskScheduleResult- where scheduled dates come back- Project data - task types, dates and durations
- Links, constraints and summaries - how links, constraints and summaries move tasks