> For the complete documentation index, see [llms.txt](https://docs.api.intratool.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.api.intratool.de/api-reference/tasks-2/task-field-default-value-sources.md).

# TaskFieldDefaultValueSources

## Introduction

`TaskFieldDefaultValueSources` define prefilled values for [TaskFields](/api-reference/tasks-2/task-fields.md).

## Model Definition

**Alias**

`defaultValueSource`

**Source Types**

* `formFieldValue` - Copies a value from another form field.
* `systemVariable` - Resolves a value from a system variable.

## Admin: Create

Create a new `TaskFieldDefaultValueSource`.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/administration/tasks-2/templates/fields/default-value-sources`

**Request Keys**

| Key                  | Type                | Default      | Description                                                                  |
| -------------------- | ------------------- | ------------ | ---------------------------------------------------------------------------- |
| `source_type`\*      | `string`            | -            | Selects one of the supported [Source Types](#source-types).                  |
| `form_field_id`\*    | `integer`           | -            | Target [TaskField](/api-reference/tasks-2/task-fields.md) ID.                |
| `config`             | `object`            | type default | Source-specific configuration.                                               |
| `source_entity_type` | `string` \| `null`  | `null`       | Morph alias of source entity (typically `formField` for field-value source). |
| `source_entity_id`   | `integer` \| `null` | `null`       | Source entity ID (required with `source_entity_type`).                       |
| `sort_number`        | `integer`           | auto         | Evaluation order per field.                                                  |

Keys with `*` are required.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/administration/tasks-2/templates/fields/default-value-sources', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'form_field_id' => 33,
        'source_type' => 'systemVariable',
        'config' => [
            'variable_key' => 'system.user.id',
            'variable_filter' => null
        ]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 52,
    "form_field_id": 33,
    "source_type": "systemVariable",
    "config": {
      "variable_key": "system.user.id",
      "variable_filter": null
    },
    "source_entity_type": null,
    "source_entity_id": null,
    "sort_number": 1
  }
}
```

## Admin: Update

Update an existing `TaskFieldDefaultValueSource`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/administration/tasks-2/templates/fields/default-value-sources/{defaultValueSource}`

**Route Parameters**

| Parameter            | Type      | Description              |
| -------------------- | --------- | ------------------------ |
| `defaultValueSource` | `integer` | Default value source ID. |

**Request Keys**

| Key                  | Type                | Description                                                 |
| -------------------- | ------------------- | ----------------------------------------------------------- |
| `source_type`        | `string`            | Selects one of the supported [Source Types](#source-types). |
| `form_field_id`      | `integer`           | New target field ID.                                        |
| `config`             | `object`            | Updated source configuration.                               |
| `source_entity_type` | `string` \| `null`  | New source entity type.                                     |
| `source_entity_id`   | `integer` \| `null` | New source entity ID.                                       |
| `sort_number`        | `integer`           | New evaluation order.                                       |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/administration/tasks-2/templates/fields/default-value-sources/52', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'source_type' => 'formFieldValue',
        'source_entity_type' => 'formField',
        'source_entity_id' => 33
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 52,
    "form_field_id": 33,
    "source_type": "formFieldValue",
    "config": {},
    "source_entity_type": "formField",
    "source_entity_id": 33,
    "sort_number": 1
  }
}
```

## Admin: Delete

Delete an existing `TaskFieldDefaultValueSource`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/administration/tasks-2/templates/fields/default-value-sources/{defaultValueSource}`

**Route Parameters**

| Parameter            | Type      | Description              |
| -------------------- | --------- | ------------------------ |
| `defaultValueSource` | `integer` | Default value source ID. |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/administration/tasks-2/templates/fields/default-value-sources/52', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": null
}
```

## Admin: List Source TaskFields

List accessible fields from administrable [Forms](/api-reference/forms/forms.md) and [TaskTemplates](/api-reference/tasks-2/task-templates.md) that can provide a `formFieldValue` default value.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/administration/tasks-2/templates/fields/default-value-sources/form-field-value/form-fields`

**Request Keys**

| Key        | Type      | Default     | Description                                             |
| ---------- | --------- | ----------- | ------------------------------------------------------- |
| `page`     | `integer` | `1`         | Result page.                                            |
| `per_page` | `integer` | API default | Results per page.                                       |
| `filter`   | `object`  | `{}`        | Standard Result Control filters, including `form_type`. |

**Behavior**

* Fields are returned only when the authenticated user can administer their parent Form or TaskTemplate.
* Each preview uses the field name as `title`, the localized parent type as `sub_title`, and the parent title as `description`.
* This endpoint uses [count-less pagination](/introduction/query-manipulation/result-control.md#count-less-pagination), so `total` is `null`.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/administration/tasks-2/templates/fields/default-value-sources/form-field-value/form-fields', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'per_page' => 10,
        'filter' => [
            'form_type' => ['is' => 'taskTemplate']
        ]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "data": [
    {
      "id": 33,
      "title": "Comment",
      "sub_title": "Task template",
      "description": "Safety Checklist",
      "additional_data": {
        "source_entity_type": "formField",
        "form_type": "taskTemplate",
        "form_id": 21,
        "form_field_type_id": "text",
        "sort_number": 1
      }
    },
    {
      "id": 34,
      "title": "Equipment operational",
      "sub_title": "Task template",
      "description": "Equipment Inspection",
      "additional_data": {
        "source_entity_type": "formField",
        "form_type": "taskTemplate",
        "form_id": 22,
        "form_field_type_id": "boolean",
        "sort_number": 2
      }
    }
  ],
  "current_page": 1,
  "total": null,
  "per_page": 10
}
```

## Admin: List Source TaskField Filters

List filters available for the source-field preview endpoint.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/administration/tasks-2/templates/fields/default-value-sources/form-field-value/form-fields/filters`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/administration/tasks-2/templates/fields/default-value-sources/form-field-value/form-fields/filters', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "data": [
    {
      "key": "form_id",
      "label": "Template",
      "type": "multi-select"
    },
    {
      "key": "form_type",
      "label": "Template Type",
      "type": "multi-select"
    }
  ]
}
```

## Admin: List Source TaskField Filter Options

List options for one multi-select source-field filter.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/administration/tasks-2/templates/fields/default-value-sources/form-field-value/form-fields/filters/{filterKey}/options`

**Route Parameters**

| Parameter   | Type     | Description                                     |
| ----------- | -------- | ----------------------------------------------- |
| `filterKey` | `string` | Multi-select filter key, for example `form_id`. |

**Request Keys**

| Key        | Type      | Default     | Description                                  |
| ---------- | --------- | ----------- | -------------------------------------------- |
| `page`     | `integer` | `1`         | Result page.                                 |
| `per_page` | `integer` | API default | Results per page.                            |
| `filter`   | `object`  | `{}`        | Filters applied before options are produced. |

**Behavior**

This endpoint uses [count-less pagination](/introduction/query-manipulation/result-control.md#count-less-pagination), so `total` is `null`.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/administration/tasks-2/templates/fields/default-value-sources/form-field-value/form-fields/filters/form_id/options', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'filter' => [
            'form_type' => ['in' => 'taskTemplate']
        ]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "data": [
    {
      "value": 21,
      "label": "Safety Checklist",
      "additionalData": {
        "form_type": "taskTemplate"
      }
    },
    {
      "value": 22,
      "label": "Equipment Inspection",
      "additionalData": {
        "form_type": "taskTemplate"
      }
    }
  ],
  "current_page": 1,
  "total": null,
  "per_page": 15
}
```

## Runtime Default Values for TaskExecutions

Resolve default values for one `TaskExecution`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/tasks-2/executions/{taskExecution}/default-values`

**Route Parameters**

| Parameter       | Type      | Description       |
| --------------- | --------- | ----------------- |
| `taskExecution` | `integer` | Task execution ID |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/tasks-2/executions/812/default-values', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "33": {
    "value": "2"
  }
}
```
