﻿# Process execution errors

> [HTML Version](360020599512.html)

This article only describes the errors that occur during the execution of business processes. You can read about modeling errors in these articles: [Publish a business process](360012495291.md) and [Validate process logic](360012267032.md).

When an error appears on a certain process step, it is displayed on the process instance page. There, you can decide how to handle the error: either skip this step or repeat it. If necessary you can also interrupt the process.

## Critical errors 

In case of a critical error, the process is interrupted, and the users included in the [Administrators](360006871932.md) group receive a message that the process was interrupted due to a critical error.



| | | |
|------|------|------|
| **Example** | **Possible cause** | **Solution** |
| Error when [creating an app item](360019810892.md). | The app where the item was supposed to be created had been deleted from the workspace. | Make sure the correct app is specified in the **Create App Item** activity. |
| Error when [editing an app item](360012454020.md). | The **main** was inaccessible so the data in the fields could not be updated. | After resolving the issue, restart the process step. |
| Error when setting a [status](360012263332.md). | The status had been deleted from the app. | Make sure valid app statuses are specified in the **Manage Status** setting. |
| Error when triggering a synchronous [subprocess](360012266792.md). | When starting a synchronous sub-process, the execution of the parent business process is suspended. If an error occurs in such a sub-process, the parent process will be interrupted. | Fix the error in the subprocess so that the main process can continue. |
| Error in a [timer event](360012496011.md): “Failed to set up timer”. | The context variable storing timer expiration value is not found or the system cannot calculate the time according to the business calendar.  | Check the value of the variable used to define the timer deadline, or review the business calendar setting. |


## Non-critical errors

In case of a non-critical error, the process continues, but the administrators are notified about the error that occurred during the execution of the process.  


| | | |
|------|------|------|
| **Example** | **Possible cause** | **Solution** |
| Error assigning a value to a context variable. | The [variable used as the right operand](360015835331.md#gateway) in the gateway transition is not populated. | Make sure the variable is assigned a value during process execution. |
| Error starting an asynchronous [subprocess](360012266792.md). | When an asynchronous subprocess is started, the main business process continues running. If an error occurs in the subprocess, the main process is not interrupted, but you will see the message "Failed to start subprocess". | Fix the error in the subprocess. |
| Error in a [notification](360012495791.md). | The variable that stores the recipient is not populated. | Check the **Notification** element settings. The recipient may be an organizational chart item that was deleted before the process reached this step. <br>Make sure the employees, groups, and organizational structure items that should receive the notification exist in the system. |
| Error assigning a [task](360012495611.md) to a user: "Failed to calculate the task deadline". | The deadline could not be calculated within the business calendar. | Check the [task duration](360012495611.md#deadline) settings. |




## Interrupt a looped business process 

A business process might get stuck at some step. For example, if an [exclusive gateway](360012495911.md) has an outgoing default connector that targets the same gateway and another connector that targets an end event but has no specified condition. In this case, the process will repeat the same step over and over again, leaving the gateway and returning back to it.

**(360020635672-mceclip2.png)**

By default, each step in the process can be repeated no more than 100 times. This helps to prevent endless execution of the process:

- In a circle, when you use an exclusive gate that is looped on itself.

- In parallel, when you start more than 100 [instances of a sub-process](360012266792.md#multiple-start).

If the number of repetitions exceeds the specified value, the process is automatically terminated, and the [supervisor](360006871932.md#supervisor) receives a corresponding notification.

### Launch a process step more than 100 times

If you need to run a business process step more than 100 times, you can use an exclusive gateway and a timer of at least three minutes. In the gateway, you can divide the total number of repetitions into several parts less than 100 times each and route the process to a timer. You need it to pause the process to reset the system repetition counter. After such a stop, this counter will re‑count the remaining steps performed in a circle. In this way, you can bypass the maximum limit of 100 repetitions.

Let's assume that the process processes 101 app items. The user adds them on the task page. Then, using the exclusive gateway, sub‑process instances are launched with each of the items. In this example, the task is assigned to the executor.

To avoid an error in the process, add the following to the diagram:

- An exclusive gateway with a script. In such a way, you divide the total number of repetitions into several parts and launch them gradually to bypass the system maximum limit of 100 repetitions.

- A **Script** activity, which counts the number of items that have passed through the gateway.

- A timer lasting at least three minutes. It pauses the process when the gateway script records 99 repetitions of the sub‑process. During this time, the system repetition counter is reset, and you can continue executing the required step with the remaining items.

**(exclusive-gateway-1.png)**

Consider these settings.

1. On the [Context](process_context.md) tab, add variables for executing scripts and configuring connectors:

- **Repetition counter**. This is a variable of the **Number** type with the **Integer** option to count the number of sub‑process repetitions in the script on the gateway.

- **Item counter**. This is a variable of the **Number** type with the **Integer** option to count the number of items for which the sub‑process needs to be launched in the **Script** activity.

- **App with items**. This is a variable of the **App** type with the **Many** option to add a field in the **Task** activity.

- **Sub-process app**. This is a variable of the **App** type with the **One** option to set up the **Start Process** activity.

2. On the **Flow Chart** tab, place the [Task](360012495611.md) activity. Place a field with the app, the items of which need to be processed, on the task template.

3. Add an exclusive gateway to the flow chart. In it, you can count the number of repetitions of the launched sub‑process instances. To do this, in the [gateway settings](360012495911.md#service-variable-tab), on the **Service Variable** tab, enable the **Use service variable in the connector conditions** option, select the **Number** type, and add the following script:

````
async function getIterationsNumber(): Promise<number> \{  
    // Count the number of iterations in the loop using the Iteration counter context variable  
    Context.data.iterator = Context.data.iterator\! + 1;  
    if (Context.data.iterator > 99) \{  // If the number of iterations in the loop is more than 99, then reset the iteration counter  
        Context.data.iterator = 0;  
    \}  
    return Context.data.iterator;    // Return the iterator counter value in the service variable  
\}

4. ````
Add a [connector](360015835331.md#gateway) from the **Task** activity to the gateway.

5. Place the [Script](360027203731.md) activity on the flow chart. Specify a function in it to receive items one by one from the task, count them, and pass them to the next step **Start Process**.

Script

````
// this script is not standard  
async function getElement(): Promise<void> \{  
    // get the last item from the general list of items to start a sub-process with it. Use the context variable Item Counter  
    if (Context.data.app) \{  
        Context.data.elements\_iterator = Context.data.app.length // get the number of remaining elements  
        Context.data.element = Context.data.app.pop(); // the pop() method removes and returns the last item from the list of items  
    \}  
\}  

````

6. ````
Add a connector from the gateway to the **Script** activity.

7. Place the [Start Process](360012266792.md) activity on the flow chart. Select a custom process in its settings. This process is used to create a task with an attached app item.

8. Add connectors from the **Script** activity to the **Start Process** activity, and from it to the gateway.

9. Put a [timer](360012496011.md#timer) on the flow chart. Specify the execution period as three minutes.

10. Add a connector from the gateway to the timer. In this connector, on the **Conditions** tab, set the following condition: Gateway service variable = 99.  
Thus, when 99 repetitions of the launched sub‑process instances are reached, the main process will go to the timer and stop for three minutes. During this time, the system repetition counter, which recorded the completed step circles, will be reset. This will allow the sub-processes with the remaining items to continue running. To do this, add a connector from the timer to the gateway. If the number of repetitions is less than 99, the process will end, bypassing the timer.

11. Add a connector to the [end event](360012496011.md#end-event). On the **Conditions** tab, set the following condition: Item counter = 0. When all items have launched their own sub-process instances, the main process will end.