# Processes

In order to be able to create new cases based on a case definition a process needs to be connected to the case definition. Valtimo uses processes (BPMN 2.0) to guide a case through an organization and gather case information needed for that specific case.

This case tab makes it possible to connect any process in that implementation to the case definition.

{% hint style="info" %}
This page requires:

* A case definition
* A process definition
  {% endhint %}

## Linking a process to the case definition

Linking processes to the case definition can be done via the UI or the IDE.

{% tabs %}
{% tab title="Via UI" %}

<figure><img src="https://3330064618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq5dx9HWFJGshztp4binE%2Fuploads%2Fgit-blob-fa5bc65a341c6bf2ee7690dd66993689a124e63e%2Fimage%20(32)%20(1).png?alt=media" alt=""><figcaption><p>Link a process</p></figcaption></figure>

When editing an existing process, the following is shown:

<div align="left" data-full-width="false"><figure><img src="https://3330064618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq5dx9HWFJGshztp4binE%2Fuploads%2Fgit-blob-1f57ead957df9844d948c03b663b4208b8907eba%2Fimage%20(33)%20(1).png?alt=media" alt=""><figcaption><p>Link a process to a case definition</p></figcaption></figure></div>

The toggles can be used to identify what type of process is being linked. Some processes are relevant when a new case is started and other processes are only relevant in certain states of the case. Be sure to press Save in order to store the changes.\\

* [x] **Process creates new case**

These types of processes generally have the start form configured that is used to create new cases. Connect the process and select the checkbox. At least one process should have this option selected, otherwise the "Create New Case" button will remain disabled.

Multiple start forms can exist for a single case and if this is configured a pre-selection modal will appear presenting available start forms when the "Create New Cas&#x65;**"** button is clicked.\\

* [x] **Can be started within existing case**

Select this checkbox for processes that support a case during a specific period or state. These processes are available under the "Start" button on any tab of the case details.\\

* [x] **Do not select anything**

Leave both checkboxes empty when a sub-process needs to be added to the case definition. In larger process models it's often helpful to move parts of the process to a sub process that can be activated via a so-called "Call activity" element in the main process.

These sub-processes are not starting processes for the case and should not appear in the Case actions menu under the Start button in the case details UI. It is important to link these sub-processes to the Case definition in order to automatically store the data that is fetched by these processes in the JSON document of that case.

For reusable sub-processes that should be shared across multiple cases, see [Building blocks](https://docs.valtimo.nl/features/building-blocks).
{% endtab %}

{% tab title="Via IDE" %}
In order to link processes to a case the following steps are necessary:

1. Create a process document link file (ending with `.json`) under the following path: `*/resources/config/case/{case-definition-key}/{version-tag}/process-document-link/`.\
   \
   The name should correspond with the document definition ID\
   (e.g. a document definition `example-case.schema.document-definition.json` with the ID `example-case.schema` requires the process document file to be named `example-case.process-document-link.json`.
2. Specify the process(es) that should be linked to the document. More than one process can be linked to the same document by adding multiple configurations to the array.

{% code title="example-case.process-document-link.json" %}

```json
[
    {
        "processDefinitionKey": "example-case",
        "canInitializeDocument": true,
        "startableByUser": true
    }
]
```

{% endcode %}

#### Independent processes linked to a case

Independent processes linked to a case can be configured to define the link type between a process and a case definition (e.g. `DOCUMENT_UPLOAD`). Create a JSON file under the following path:

`*/resources/config/case/{case-definition-key}/{version-tag}/case-definition-process-link/`

The file name should end with `.case-definition-process-link.json`.

{% code title="example-case.case-definition-process-link.json" %}

```json
[
    {
        "processDefinitionKey": "document-upload",
        "linkType": "DOCUMENT_UPLOAD"
    }
]
```

{% endcode %}

| Property               | Description                                |
| ---------------------- | ------------------------------------------ |
| `processDefinitionKey` | The key of the process definition to link. |
| `linkType`             | The type of link (e.g. `DOCUMENT_UPLOAD`). |
| {% endtab %}           |                                            |
| {% endtabs %}          |                                            |
