# Subprocesses

## What is a subprocess <a href="#podprocesy-utworzeniepodprocesu" id="podprocesy-utworzeniepodprocesu"></a>

**Workflow subprocess** (Eng. *subprocess*) is a separated fragment of a larger business process that performs a specific, repetitive set of activities. It is used to organize and modularly design workflows - thanks to this, complex processes can be divided into smaller, easier-to-manage parts.

Subprocesses make it easier to reuse the same procedures in different parts of the system, increase the clarity of BPMN diagrams, and allow independent testing and modification of individual stages of the process. As a result, the organization gains greater flexibility, consistency, and easier maintenance of its business processes.

## Working with subprocesses <a href="#podprocesy-utworzeniepodprocesu" id="podprocesy-utworzeniepodprocesu"></a>

### Creating a subprocess <a href="#podprocesy-utworzeniepodprocesu" id="podprocesy-utworzeniepodprocesu"></a>

We create and save a subprocess in the same way as a process.

### Adding a subprocess to a process <a href="#podprocesy-dodaniepodprocesudoprocesu" id="podprocesy-dodaniepodprocesudoprocesu"></a>

When editing the process to which we want to add a previously created subprocess, in the main process we add an element of type **Task**.

Then we change its type to **Call Activity** (context menu **Change element** will be displayed after selecting the block and clicking the key icon).

<figure><img src="/files/42ffc33e6c9d2d943caf0b34825851d305014f27" alt=""><figcaption><p><em><strong>Figure 1.</strong> Task type change menu</em></p></figcaption></figure>

In the next step, for the selected block **Call Activity** in the right panel we expand the **Called element**. First we set the element type (property **Type**) to **BPMN**, and after expanding the next fields we enter in the field **Called element** the process created earlier - placing it as a subprocess in the edited process.

<figure><img src="/files/360c1dba6cd40f789c44b4521a6a195186cfdddd" alt=""><figcaption><p><em><strong>Figure 2.</strong> "Call Activity" menu</em></p></figcaption></figure>

### Subprocesses and dependencies

Since a subprocess is part of another process, when saving the process definition in the version save window we will receive information about dependent artifacts.

<figure><img src="/files/09fb48ffbfe60e960cb7b3311ab377fa4a701791" alt=""><figcaption></figcaption></figure>

Because of such a dependency, it is impossible to delete the subprocess definition from the repository.

<figure><img src="/files/8a0cb4f67dbe7f74f7292421ba64b261670a0364" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Deleting the main process is possible and is not confirmed by any window. However, a message appears at the bottom of the screen allowing you to undo this operation.
{% endhint %}

When downloading the artifact of a process that is the main process (option **Download** in the context menu of a given process), the subprocess of this process will also be downloaded.

```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<exportArtifactWithDependencies>
    <dependencies>
        <dependency>
            <additionalData></additionalData>              
            <content>PD94bXZlbnQ{...}XRpb25zPgo=</content>
            <folderPath>/developers/mwachowska/</folderPath>
            <majorVersion>1</majorVersion>
            <minorVersion>6</minorVersion>
            <name>podproces.bpmn</name>
            <type>bpmn</type>
        </dependency>
    </dependencies>
    <exportArtifact>
        <additionalData></additionalData>
        <content>PD94bW{...}lvbnM+Cg==</content>
        <folderPath>/developers/mwachowska/</folderPath>
        <majorVersion>1</majorVersion>
        <minorVersion>3</minorVersion>
        <name>proces_glowny.bpmn</name>
        <type>bpmn</type>
    </exportArtifact>
</exportArtifactWithDependencies>
```

When importing into an application a process that has subprocesses, they will also be automatically added to that application

### Versioning and use of subprocesses

In the **Binding** we can specify the subprocess version.

* By default, latest is set, meaning always the newest version.
* However, we can indicate a specific version (version) or bind the subprocess version to the deployment of the main process (deployment).

The same subprocess **can be used in many main processes**, so its update may affect all related processes. After testing and before production deployment, it is recommended to bind it to a specific stable version.

Open instances always use the version of the subprocess that existed when the main process was started. New instances, if Binding = latest, will use the new version of the subprocess.


---

# 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.eximee.com/documentation/documentation-en/budowanie-aplikacji/proces-biznesowy/tworzenie-procesu-biznesowego-w-bpmn-2.0/podprocesy.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.
