[Canonical page](<https://docs.dhtmlx.com/planning-engine/js/api/types/assignment-data/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# AssignmentData

A plain object that books one resource on one task at a given rate. Pass these records in [`ProjectData.assignments`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) to load a plan, or in the `assignments.add` bucket of a [`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/js/api/types/scheduling-changes.md>) to add bookings later. An assignment changes resource load. Its `offset` and `duration` never move task dates.

## Fields

| Field | Type | Default | Description |
|---|---|---|---|
| `id` | [`Id`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#id>) \| `null` | generated | Unique among assignments. Without an id, the assignment gets a generated one; `apply` lists it in [`effects.generatedAssignments`](<https://docs.dhtmlx.com/planning-engine/js/api/project-apply.md#changeeffects>). Updates and removals address the assignment by this id. |
| `task` | [`Id`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#id>) | required | The task being booked. Must name a task of the plan. `task_id` is accepted as an alias; `task` wins when both are present. |
| `resource` | [`Id`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#id>) | required | The booked resource. Must name a resource of the plan. `resource_id` is accepted as an alias; `resource` wins when both are present. |
| `value` | `number` | required | Booking rate in resource capacity units: `1` = 100 %. Must be finite and greater than 0. |
| `offset` | `number` \| `null` | `0` | Where the booked slice starts: worked time from the task start, in the task's `duration_unit`. Must be finite and at least 0. `null` reads as the default. |
| `duration` | `number` \| `null` | to the task end | Length of the booked slice: worked time, in the task's `duration_unit`. Must be finite and greater than 0. `null` reads as the default. |

Worked time for `offset` and `duration` is counted on the assignment's working calendar and skips non-working time and pauses, so the slice moves with the task's work. The slice is clipped to the task's work when load is booked, not when the record is read: an `offset` at or past the task's duration books nothing, and a slice follows a task that later gets shorter. Several assignments of one resource on one task each book their own slice, and overlapping slices add up.

An assignment on an unscheduled task stays in the project and books nothing until the task is scheduled again; the result reports it as a `dropped-assignment` [note](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md>).

Invalid values (an unknown task or resource, a duplicate id, a bad `value`, `offset` or `duration`) throw an [`InputError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) with a path such as `assignments[0].value` when the plan is loaded, and come back as a rejected operation from `apply`. With `validation: "repair"` on the [`Project`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md>), an invalid `offset` or `duration` is cleared and a duplicate id replaces the earlier record, each reported as a `repaired` note. Unknown fields are ignored.

## Used by

- [`Project#solve`](<https://docs.dhtmlx.com/planning-engine/js/api/project-solve.md>), [`Project#analyze`](<https://docs.dhtmlx.com/planning-engine/js/api/project-analyze.md>), [`schedule`](<https://docs.dhtmlx.com/planning-engine/js/api/schedule.md>): `data.assignments` holds the plan's bookings
- [`Project#apply`](<https://docs.dhtmlx.com/planning-engine/js/api/project-apply.md>), [`Project#preview`](<https://docs.dhtmlx.com/planning-engine/js/api/project-preview.md>), [`Project#evaluate`](<https://docs.dhtmlx.com/planning-engine/js/api/project-evaluate.md>): `changes.assignments.add` adds bookings
- [`Project#suggestAssignments`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md>): returns filled slots as `changes.assignments.add` entries

## Example

```js
const assignments = [
  // Ann works full time on task 1.
  { id: "a1", task: 1, resource: "ann", value: 1 },
  // Bob works half time on task 1 for 2 working days, starting after its first
  // working day (task duration_unit: "day").
  { id: "a2", task: 1, resource: "bob", value: 0.5, offset: 1, duration: 2 },
];
```

## Related

- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) - the plan that carries `assignments`
- [`ResourceData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#resourcedata>) - the resource an assignment books
- [`AssignmentUpdate`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#linkupdate-resourceupdate-assignmentupdate>) - editing an existing assignment
- [Resources and assignments](<https://docs.dhtmlx.com/planning-engine/js/resources-and-assignment/resources-and-assignments.md>) - capacity, assignments and overallocation
- [Split assignment work](<https://docs.dhtmlx.com/planning-engine/js/how-to/split-assignment-work.md>) - booking part of a task with `offset` and `duration`
