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


# ResourceUpdate

An edit to one existing resource of a live project. It goes in the `Update` list of [`SchedulingChanges.Resources`](<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 ResourceUpdate(id)` and set the fields to change in an object initializer. To add a resource, put a [`ResourceData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/resource-data.md>) in `SchedulingChanges.Resources.Add` instead.

## Declaration

```csharp
namespace Plen;

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

## Constructors

### ResourceUpdate(Id)

```csharp
public ResourceUpdate(Id id)
```

Creates an update for the resource with the given id. `Capacity` and `CalendarId` start as [`Patch<T>.Missing`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/patch.md#missing>), so the update changes nothing until one of them is set.

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

## Properties

`Capacity` and `CalendarId` are [`Patch<T>`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/patch.md>) values. `Missing` (the default) keeps the stored value, a value sets it, and `Null` clears it. The **On `Null`** column shows what `Null` leaves behind. For the meaning of each value, see the property of the same name on [`ResourceData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/resource-data.md#properties>).

A plain `double` converts implicitly, so `Capacity = 2.0` works. `CalendarId` 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 resource to edit. |
| `Capacity` | `Patch<double>` | `null`, so [`SchedulingConfig.DefaultResourceCapacity`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/scheduling-config.md#defaultresourcecapacity>) applies | New capacity, in the same scale as assignment `Value` (`1` = 100 %). |
| `CalendarId` | `Patch<Id>` | `null`, no calendar of its own | New working calendar of the resource. |

## Dates after an update

In [`CalendarMode.Resource`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/calendar-mode.md>) with `UseCalendars` on, a `CalendarId` change can change the calendars that a leaf task's assignments work on. Each leaf task whose set of working calendars changes keeps its start and duration and gets its end derived again. In the `Task` and `TaskInherited` modes, the update doesn't move any dates. How a resource calendar combines with a task calendar is covered in [Resource calendars](<https://docs.dhtmlx.com/planning-engine/net/scheduling/working-time-calendars.md#resource-calendars>).

## Methods

### DeepClone

```csharp
public ResourceUpdate DeepClone()
```

Returns a copy with the same `Id`, `Capacity` and `CalendarId`.

### ToString

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

Returns a readable rendering of `Id`, `Capacity` and `CalendarId`, for logging. Each patch shows its state: `Missing`, `Null` or the carried value.

## Errors

An update is rejected as a single operation, at path `resources.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 resource id` | No resource has `Id`. |
| a validation message | The edited resource breaks a [`ResourceData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/resource-data.md#errors>) rule: `Capacity` is negative, `NaN` or infinite, or, in [`CalendarMode.Resource`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/calendar-mode.md>), `CalendarId` names no calendar. |

## Example

Double a resource's capacity and drop its own calendar:

```csharp
using Plen;

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

var data = new ProjectData
{
    Tasks =
    [
        new TaskData("design") { StartDate = monday, Duration = 2.0 },
        new TaskData("build") { StartDate = monday, Duration = 2.0 },
    ],
    Resources = [new ResourceData { Id = "dev1", Capacity = 1.0 }],
    Assignments =
    [
        new AssignmentData { Task = "design", Resource = "dev1", Value = 1.0 },
        new AssignmentData { Task = "build", Resource = "dev1", Value = 1.0 },
    ],
};

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

var changes = new SchedulingChanges();
changes.Resources.Update.Add(new ResourceUpdate("dev1")
{
    Capacity = 2.0,
    CalendarId = Patch<Id>.Null,
});

var report = project.Apply(changes);
if (report.Rejected.Count == 0)
{
    var result = project.Solve(null, new SolveOptions());
    Console.WriteLine($"Overallocated resources: {result.Overallocations?.Count ?? 0}");
}
```

## Related

- [`ResourceData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/resource-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
- [Editing a project](<https://docs.dhtmlx.com/planning-engine/net/live-projects/editing-a-project.md>) - the full edit cycle
