# TaskFieldDefaultValueSources

## Introduction

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

## \[Adm.] Create

**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          | -            | Allowed values: `formFieldValue`, `systemVariable`.                          |
| `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**

```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
        ]
    ]
]);
```

**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
  }
}
```

## \[Adm.] Update

**Definition**

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

**Request Keys**

| Key                  | Type            | Description                                           |
| -------------------- | --------------- | ----------------------------------------------------- |
| `source_type`        | string          | New source type (`formFieldValue`, `systemVariable`). |
| `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**

```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
    ]
]);
```

**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
  }
}
```

## \[Adm.] Delete

**Definition**

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

**Request Keys**

No additional request keys.

**Example Request**

```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}"]
]);
```

**Example Response**

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

## Runtime default values for task executions

Resolved default values for a specific execution are returned by:

**Definition**

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

**Request Keys**

| Key             | Type    | Default | Description       |
| --------------- | ------- | ------- | ----------------- |
| `taskExecution` | integer | -       | Task execution ID |

**Example Request**

```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}"]
]);
```

**Example Response**

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.intratool.de/api-reference/tasks-2/task-field-default-value-sources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
