[Canonical page](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/assignment-update/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# AssignmentUpdate

An edit to one existing assignment of a live project. It goes in the `Update` list of [`SchedulingChanges.Assignments`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/scheduling-changes.md>), which [`Project.Apply`](<https://docs.dhtmlx.com/planning-engine/net/api/project-apply.md>) and [`Project.Preview`](<https://docs.dhtmlx.com/planning-engine/net/api/project-preview.md>) take. Create it with `new AssignmentUpdate(id)` and set the fields to change in an object initializer.

## Declaration

```csharp
namespace Plen;

public sealed class AssignmentUpdate : IDeepCloneable<AssignmentUpdate>
```

## Constructors

### AssignmentUpdate(Id)

```csharp
public AssignmentUpdate(Id id)
```

Creates an update for the assignment with the given id. Every other property is [`Patch<T>.Missing`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/patch.md#missing>), so the update changes nothing until a property is set.

| Name | Type | Description |
|---|---|---|
| `id` | [`Id`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/id.md>) | Id of the assignment to edit. A `string`, `int` or `double` converts implicitly. |

## Properties

Every property except `Id` is a [`Patch<T>`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/patch.md>). `Missing` (the default) keeps the stored value, a value sets it, and `Null` clears it. The **On `Null`** column shows what `Null` does. For the meaning of each value, see the property of the same name on [`AssignmentData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/assignment-data.md#properties>).

A plain value converts implicitly to a `Patch<T>`, so `Value = 0.5` works. An `Id` property needs `Patch<Id>.Of(...)` when the value is a `string` or a number, because C# doesn't chain the two implicit conversions.

| Property | Type | On `Null` | Description |
|---|---|---|---|
| `Id` | [`Id`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/id.md>) | required | Id of the assignment to edit. |
| `Task` | `Patch<Id>` | rejected | Moves the assignment to another task. |
| `Resource` | `Patch<Id>` | rejected | Gives the assignment to another resource. |
| `Value` | `Patch<double>` | rejected | New units booked. |
| `Offset` | `Patch<double>` | `null` | New start of the slice. `null` books from the task start. |
| `Duration` | `Patch<double>` | `null` | New length of the slice. `null` books up to the task end. |

The edited assignment must still meet the [`AssignmentData` rules](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/assignment-data.md#errors>): `Value` and `Duration` greater than `0`, `Offset` `0` or greater, and `Task` and `Resource` naming existing records.

## Effect on dates

- `Offset`, `Duration` and `Value` change resource load only. They never move a task.
- `Task` and `Resource` move dates only when the task then works on a different set of calendars, for example when the new resource has its own calendar in [`CalendarMode.Resource`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/calendar-mode.md>).
- Moving an assignment to an unscheduled task keeps it in the project without booking load. Its id is listed in [`ChangeEffects.DroppedAssignments`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/apply-report.md#changeeffects>).

## Methods

### DeepClone

```csharp
public AssignmentUpdate DeepClone()
```

Returns a copy with the same property values.

**Returns**: a new `AssignmentUpdate`.

### ToString

```csharp
public override string ToString()
```

Returns a debug dump of the fields, e.g. `AssignmentUpdate { Id: a1, Task: Missing, Resource: Missing, … }`.

## Errors

An update is rejected as a single operation, at path `assignments.update[i]`. [`Project.Apply`](<https://docs.dhtmlx.com/planning-engine/net/api/project-apply.md>) and [`Project.Preview`](<https://docs.dhtmlx.com/planning-engine/net/api/project-preview.md>) describe how a rejection is reported.

| Message | When it occurs |
|---|---|
| `unknown assignment id` | No assignment has `Id`. |
| `required field cannot be null` | `Task`, `Resource` or `Value` is `Null`. |
| a validation message | The edited assignment breaks an [`AssignmentData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/assignment-data.md#errors>) rule, for example an unknown `Resource` or a `Value` of `0`. |

## Example

Hand Ben's review to Cara and narrow it to the last day of the task:

```csharp
using Plen;

var start = Moment.FromYmdHm(2026, 4, 6, 8, 0)
    ?? throw new InvalidOperationException("invalid date");

var data = new ProjectData
{
    Tasks = [new TaskData(1) { StartDate = start, Duration = 5.0 }],
    Resources =
    [
        new ResourceData { Id = "ben" },
        new ResourceData { Id = "cara" },
    ],
    Assignments =
    [
        new AssignmentData { Id = "review", Task = 1, Resource = "ben", Value = 0.5 },
    ],
};

var project = new Project();
project.Solve(data, new SolveOptions());

var changes = new SchedulingChanges();
changes.Assignments.Update.Add(new AssignmentUpdate("review")
{
    Resource = Patch<Id>.Of("cara"),
    Offset = 4.0,
    Duration = 1.0,
});

var report = project.Apply(changes);
foreach (var rejected in report.Rejected)
{
    Console.WriteLine($"{rejected.Path}: {rejected.Message}");
}
```

## Related

- [`AssignmentData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/assignment-data.md>) - the record being edited
- [`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/scheduling-changes.md>) - the change set that carries the update
- [`Patch<T>`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/patch.md>) - the three-state field type
- [`Project.Apply`](<https://docs.dhtmlx.com/planning-engine/net/api/project-apply.md>) - commits the change set
- [Split assignment work](<https://docs.dhtmlx.com/planning-engine/net/how-to/split-assignment-work.md>) - editing slices with updates
