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


# TaskData

One task in [`ProjectData.Tasks`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/project-data.md>) or in a [`SchedulingChanges.Tasks`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/scheduling-changes.md>)`.Add` list. Create it with `new TaskData(id)` and set the other properties in an object initializer. To change a task that a project already holds, send a [`TaskUpdate`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/task-update.md>) instead.

## Declaration

```csharp
public sealed class TaskData : IDeepCloneable<TaskData>
```

A leaf task needs two of `StartDate`, `EndDate` and `Duration`. A summary takes both dates or neither, and a milestone takes one date. [Project data](<https://docs.dhtmlx.com/planning-engine/net/scheduling/project-data.md#tasks>) explains these date rules, and [Validation rules](<https://docs.dhtmlx.com/planning-engine/net/scheduling/project-data.md#validation-rules>) lists the input that strict validation rejects.

## Constructors

### TaskData(Id)

```csharp
public TaskData(Id id)
```

Creates an auto-scheduled task of type `Task` with priority 500, no dates and every other property at its default.

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

## Properties

| Property | Type | Default | Description |
|---|---|---|---|
| `Id` | [`Id`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/id.md>) | required | Task id. Unique among the project's tasks. |
| `Parent` | `Id?` | `null` | Id of the parent summary. `null`, `""` and a value equal to [`SchedulingConfig.RootId`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/scheduling-config.md#rootid>) all mean a root task. |
| `TaskType` | [`TaskType`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/task-data.md#tasktype>) | `TaskType.Task` | Leaf task, summary or milestone. Wire name `type`. |
| `StartDate` | [`Moment?`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/moment.md>) | `null` | Start date. |
| `EndDate` | `Moment?` | `null` | End date. |
| `Duration` | `double?` | `null` | Working time in `DurationUnit`. |
| `DurationUnit` | [`TimeUnit?`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/time-unit.md>) | `null` | Unit of `Duration`, `LevelingDelay` and `Pauses`. `null` uses [`SchedulingConfig.DurationUnit`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/scheduling-config.md#durationunit>). |
| `ConstraintType` | [`ConstraintType?`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/task-data.md#constrainttype>) | `null` | Scheduling constraint. `null` means no constraint. Constraints act only when [`SchedulingConfig.ApplyConstraints`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/scheduling-config.md#applyconstraints>) is on. |
| `ConstraintDate` | `Moment?` | `null` | Date of a dated constraint. Required when `ConstraintType` is a dated constraint. |
| `AutoScheduling` | `bool` | `true` | `false` makes the task fixed: the planner never moves it. |
| `Unscheduled` | `bool` | `false` | `true` keeps the task in the data but out of the plan. An unscheduled task needs no dates and isn't reported. |
| `Progress` | `double` | `0.0` | Completed fraction, from 0 to 1. With [`SchedulingConfig.UseProgress`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/scheduling-config.md#useprogress>) on, `1` marks the task as completed. |
| `Priority` | `ushort` | `500` | Leveling priority, 0 to 1000. `1000` means the task is never leveled. |
| `LevelingDelay` | `double` | `0.0` | Delay added by leveling, as elapsed (wall-clock) time in the task's duration unit. Rounded to whole minutes on use. |
| `Pauses` | `List<`[`Pause`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/pause.md>)`>` | empty | Leveling splits in the task's work, sorted by `At` and non-overlapping. Empty means uninterrupted work. Ignored on summaries, milestones and unscheduled tasks. |
| `CalendarId` | `Id?` | `null` | The task's own calendar. `null` uses the global calendar, or the parent's calendar in [`CalendarMode.TaskInherited`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/calendar-mode.md>). |

`LevelingDelay` and `Pauses` normally come from [`Project.Level`](<https://docs.dhtmlx.com/planning-engine/net/api/project-level.md>). Setting `Pauses` to an empty list and `LevelingDelay` to `0` clears a task's leveling. See [Leveling resources](<https://docs.dhtmlx.com/planning-engine/net/resources-and-assignment/leveling-resources.md>).

## Methods

### DeepClone

```csharp
public TaskData DeepClone()
```

Returns a copy that shares no list or nested record with this task, including `Pauses`.

**Returns**: a new `TaskData` with the same values.

### ToString

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

Returns a debug dump of the fields, e.g. `TaskData { Id: a, Parent: null, TaskType: Task, … }`.

## TaskType

The kind of a task, set in `TaskData.TaskType`.

```csharp
public enum TaskType { Task, Summary, Milestone }
```

| Value | Description |
|---|---|
| `Task` | A leaf task. The default. |
| `Summary` | A summary task whose span covers its children. The wire value `"project"` also reads as `Summary`. |
| `Milestone` | A zero-duration milestone. |

## ConstraintType

A task's scheduling constraint, set in `TaskData.ConstraintType`. All values except `Asap` and `Alap` are dated and need `ConstraintDate`.

```csharp
public enum ConstraintType { Asap, Alap, Snet, Snlt, Fnet, Fnlt, Mso, Mfo }
```

| Value | Description |
|---|---|
| `Asap` | As soon as possible. |
| `Alap` | As late as possible. |
| `Snet` | Start no earlier than `ConstraintDate`. |
| `Snlt` | Start no later than `ConstraintDate`. |
| `Fnet` | Finish no earlier than `ConstraintDate`. |
| `Fnlt` | Finish no later than `ConstraintDate`. |
| `Mso` | Must start on `ConstraintDate`. |
| `Mfo` | Must finish on `ConstraintDate`. |

The enum has no parsing or spelling helpers. JSON spellings (the lowercase names) are handled by the `Plen.Wire` package. See [Links, constraints and summaries](<https://docs.dhtmlx.com/planning-engine/net/scheduling/links-constraints-summaries.md#constraints>) for how the planner applies each constraint.

## Example

```csharp
using Plen;

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

var data = new ProjectData
{
    Config = new SchedulingConfig { ApplyConstraints = true },
    Tasks =
    [
        new TaskData("phase") { TaskType = TaskType.Summary },
        new TaskData("design") { Parent = "phase", StartDate = monday, Duration = 3 },
        new TaskData("review")
        {
            Parent = "phase",
            StartDate = monday,
            Duration = 4,
            DurationUnit = TimeUnit.Hour,
            ConstraintType = ConstraintType.Snet,
            ConstraintDate = Moment.FromYmdHm(2026, 3, 9, 8, 0),
        },
        new TaskData("release") { TaskType = TaskType.Milestone, StartDate = monday, AutoScheduling = false },
    ],
};

var result = Engine.Schedule(data, new SolveOptions());
```

## Related

- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/project-data.md>) - the snapshot that holds tasks
- [`TaskUpdate`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/task-update.md>) - edits an existing task
- [`SchedulingConfig`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/scheduling-config.md>) - project-wide defaults for tasks
- [Project data](<https://docs.dhtmlx.com/planning-engine/net/scheduling/project-data.md>) - date rules and validation
- [Links, constraints and summaries](<https://docs.dhtmlx.com/planning-engine/net/scheduling/links-constraints-summaries.md>) - constraints and summary tasks
