﻿# Automatic approval

> [HTML Version](auto-approval.html)

You can set up automatic approval of a [document](360009923631.md), [app item](360016427291.md) or [file](360014164452.md) using the [Approval](360010366380.md) activity. In this case, the decision on the document is executed in a separate task that should be placed on the process diagram before the **Approval** activity.

In this task, the employee will make a decision to **Approve** or **Reject** through the standard interface. Then the process will move to the **Approval** activity, which will be executed automatically. The corresponding decision will be made and an [approval sheet](approval-sheets.md) will be created, where this decision will be recorded.

Use this method when it is enough to click one button in a task and specify a comment to make a decision on a document. The approver can also attach a file to their decision.

To do this, place the [task](360012495611.md) where the employee will make a decision on the document on the process diagram. Then set up two connectors from this task, **Approve** and **Reject**. After each connector, place the **Approval** activity and specify in its settings what decision will be made if the process goes along this path.

**Important**: For automatic approvals, the **Approval** activity is placed on the diagram twice: one for the **Approved **decision, and one for the **Rejected** decision made by the user in the previous task.

**(automatic_approval_01.png)**

Please note, with automatic approvals:

- There is no signing of the document.

- Only one connector to the next step of the process according to the decision can be configured from the **Approval** activity. You can also set the connector that will be executed if an error occurs.

- By default, the final resolution is displayed in the [approval sheet](approval-sheets.md) after the process is completed. Until then, users see the **Pending approval** status. To generate a final **Approved** or **Rejected** resolution after reviewing a document, file, or app item, use the [End Approval](360011756780.md) activity.

## Preliminary setup

Let’s consider an example of preliminary setup for approving an incoming invoice:

1. Add the following variables to the process context to the [process context](process_context.md).

- **Incoming invoice** of the **Files** or **App** type and the **One** option. This references the document sent for approval.

- **Comment** of the **String** type. The approver’s comment will be written to this variable.

- **File** of the **Files** type and the **One** option. This stores the file attached by the approver to their decision.

2. Place the **Approve incoming invoice** task on the process diagram before the **Approval** activity. In this task, the approver will make a decision on the document and can add a comment and attach a file to their decision.

3. In the settings of the **Approve** **incoming invoice** task:

- On the **Form** tab, add the **Comment** and **File** variables to the task form. Mark the **Comment** field as required. In the settings for this variable, add a prompt about the mandatory nature of this field if the invoice is rejected.

- On the **Connectors** tab, configure two outgoing connectors. For the **Reject** button let’s enable the validation of the mandatory field **Comment**.

**(automatic_approval_02.png)**

Once the executor completes the **Approve incoming invoice** task, the process will move to the **Approval** activity, which will be executed automatically.

## Configure automatic approval

On the process diagram, configure two **Approval** activities. In one of them set the decision **Rejected** and in the other one set the decision **Approved**.

To go to the activity settings, double-click on its shape in the process diagram. The settings window contains the **General**, **Notifications**, **Error Handling**, and** Description **tabs.

### General tab

**(automatic_approval_03.png)**

- **Name\***.** **Enter a name that will be displayed in the process diagram;

- **Task name\***.** **The text entered in this field will be seen by the executor in the task list or on the task page, if [manual](360010366380.md#general_tab) approval is set up;

- **Item to send for approval\***.** **Specify the [context variable](process_context.md) that refers to a file or app;

- **Write the output to a variable**. Specify a variable of the **String** type to which the code of the result of the current activity execution will be written. The result depends on the value selected below in the **Decision\*** field. Accordingly, \[OBJECT\] or \[OBJECT\]  will be written to the specified variable. If the agreement is terminated, the \[OBJECT\] value will be written. This variable can be placed on the app form, as well as used in [gateways](360012495911.md) or [scripts](360027203731.md).

- **Approval method**. Select the **Automatically** option. Then the following fields will be displayed below:

	- **Decision\***. Select the option that will be displayed in the approval sheet.

	- **Comment**, **Attachment**. Specify the variable, the value of which will be displayed in the approval sheet together with the selected decision. Please note, that the variable must be filled in before the process moves to the **Approval** activity.

### Notifications tab

You can notify users about the start of an approval and when a result is received. To do this, enable the following options on the **Notifications** tab:

**(automatic_approval_04.png)**

- **Approval start notification**. A message will be sent to the [associated activity stream](360014352191.md) of the file, document, or app item, notifying participants that the approval process has been launched. 

In the **Message** **text** field, you can enter information for the user. You can use context variables to personalize the notification, for example, to include a participant’s comment. To do this, click the **\{+\} **icon in the top right corner of the field. You can also [add a condition or function](360007679591.md#conditions-and-functions) to generate the message based on a template.

- **Approval result notification**. A notification will appear in the object’s activity stream once the approval process is complete, including the decision. The message will also display the value of the variable specified in the **Comment** field on the **General** tab.

### Error Handling tab

For automatic approval, you can select users who will receive a notification when an error occurs, as well as specify which path the process will follow in that case.

Please note that interrupting the process requires a separate connector on the process diagram. You cannot use the main connector from the activity that is used for successful approval. If no connector is specified, interruption is considered disabled.

**(auto_appoval_04.png)**

### Description tab

Specify service information about the activity's operation. System administrators and employees modeling the process will be able to access this tab and review the data. 

When the settings are complete, click **Save**.