> For the complete documentation index, see [llms.txt](https://docs.docontrol.io/docontrol-user-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docontrol.io/docontrol-user-guide/workflows/define-workflow-settings/action-settings/flow-control.md).

# Flow control

You can create different paths in your workflow to control the flow:

<table><thead><tr><th width="208.66666666666669">Flow control option</th><th>Description</th></tr></thead><tbody><tr><td><a href="#conditional">Conditional</a></td><td>Defines a logic with two subsequent True and False actions.</td></tr><tr><td><a href="#array-filter">Array filter</a></td><td>Creates a subset with all elements that meet a defined condition. If no elements meet the condition, an empty array is returned.</td></tr><tr><td><a href="#event-filter">Event filter</a></td><td>Creates a subset of aggregated events based on defined conditions. The subsequent actions in the workflow will run only on the event subset.</td></tr><tr><td><a href="#end-workflow">End workflow</a></td><td>Ends the workflow execution with Success or Warning status.</td></tr></tbody></table>

## Conditional

The Conditional action results in two outcomes: **True** or **False**. Each outcome branches out the workflow into different paths based on output from the conditional action. You can create a [loop](/docontrol-user-guide/workflows/define-workflow-settings/action-settings.md#loops) connection between the Conditional action and any previous action in the workflow:

![](https://3236294211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MesrnyDMZGYg1V-tOBo%2Fuploads%2Fl9CM7nDLirE57g6QYn05%2Fimage.png?alt=media\&token=4b8d8d6e-c247-4bee-821e-884fd871ef84):

#### To add a conditional flow control action:

1. In the **Actions** left pane, select **Flow control.** Drag the Conditional action to the canvas, and connect it to the previous action.
2. Click the action to open its settings.&#x20;
3. Enter the [condition values](#condition-values).
4. Add and connect the required outcome actions - True and False - to the Conditional action in one of these ways:
   * Add two new actions to the canvas and connect them to the Conditional action.
   * Add a new action to the canvas and connect it to the Conditional action, then connect the Conditional action to its previous actions by [loop](/docontrol-user-guide/workflows/define-workflow-settings/action-settings.md#loops).
5. After adding new actions, click on each action to open its settings, and enter the field values.

### Condition values

The values in the condition are based on the triggering event. Each condition consists of an input value, an operator, and an input value to check against.

<img src="https://3236294211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MesrnyDMZGYg1V-tOBo%2Fuploads%2F1J5xWI5f47Jm479tpEkN%2Fimage.png?alt=media&amp;token=c5282682-5e04-4f24-a2ac-b73f7dd71849" alt="" data-size="original">

#### To define  condition values: <a href="#to-define-the-trigger-settings" id="to-define-the-trigger-settings"></a>

1. Click **+And** or **+Or** to define as many conditions as needed.
2. Use a valid JSON array to enter an array of values.
3. Define a condition on **All** array elements or on **At least one**.
4. From the first condition field, enter the condition values in one of these ways:
   * **Select from event** (default): Select an event tag from the dropdown list. &#x20;
   * **Use query**: Enter the query expression using the **Query event fields** window, containing details from the event in JSONata. The event values in the query are sample values coming from the last event registered in the system. \
     A quicker way to add the query is using one of the macros from the list appearing at the top of the query page (macros are per SaaS application, depending on the selected event).&#x20;
   * **Select from previous action**: Get values from a previous action by clicking the dropdown list, selecting an action, then using the query tool to get the value.\
     ![](https://3236294211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MesrnyDMZGYg1V-tOBo%2Fuploads%2FyM7B6cRBczs5laxGts52%2Fimage.png?alt=media\&token=3966f2e5-ff77-4014-9fd0-9ab0610d55e8)
5. From the comparator dropdown list, select the comparator.
6. From the second condition field, enter the condition value to check against.&#x20;

## Array filter

Workflow events might contain an array of elements. With an array filter, you can create a subset with all elements that meet a defined condition. If no elements meet the condition, an empty array is returned.

#### Use case

For sharing on Google Drive, an organization might want to remove only collaborators who are outside of the organization's trusted domain, but not within the trusted domain.

The **change user access** event holds an array of all targets (collaborators). You can filter the array by a condition and leave only a subset of elements that satisfy the condition, such as collaborators within a trusted domain. This subset of collaborators is a filtered array, and becomes the input for the Remove collaborator remediation action.

#### &#x20;To create a subset of collaborators outside of your organization's trusted domain:

1. In Workflows > Trigger, create a **Google Drive > Change user access** event.
2. Add a condition using the Get collaborators macro.
3. Add a condition that at least one of the collaborators (targets) is not in a trusted domain, for example, gmail accounts.
4. Drag the **Array filter** action into the canvas.
5. Set the Get collaborators macro as an input of the Array filter step.
6. For the filter array, specify that array elements are **not in trusted domains**.
7. Add the **Remove collaborator** action.

After the workflow runs, any collaborators with a gmail account are removed from the shared file.

<figure><img src="https://3236294211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MesrnyDMZGYg1V-tOBo%2Fuploads%2FPReIx0N6NVFyJBAzVKUU%2FArray%20filter.gif?alt=media&amp;token=5b88a55b-4472-47c8-9db8-5c3e25a03982" alt=""><figcaption></figcaption></figure>

## Event filter

Aggregated workflows can aggregate up to 5000 events of the same type within a 30-second timeframe. Each one of these events contains different assets and data and might result in different execution statuses. Therefore each subset of use cases needs to be handled differently within the same workflow.

With the Event filter action, you can create a subset of aggregated events based on defined conditions. The subsequent actions in the workflow will run only on the event subset.

#### **Use cases**

There are several use cases for the Event filter action:

* **PII and regex scanning in aggregated mode** - An aggregated workflow might scan multiple assets for sensitive data. Only a subset of these events actually contains sensitive data, so you can use an Event filter to act only on those files that match for sensitive data.&#x20;
* **In-workflow error handling** - Use an Event filter to act only on assets with a warning or failed status, and send them to the security team in Slack.
* **Shadow apps** - When removing several apps in one action, you can use an Event filter to provide different steps for different app risk scores. For example, remove apps that have a risk score of 7 and above, but don't remove apps with a risk score under 7.

{% hint style="warning" %}
The Event filter action step is only available in aggregated workflows.
{% endhint %}

#### To add an event filter action:

1. In the **Actions** left pane, select **Flow control.** Drag the **Event filter** action to the canvas, and connect it to the previous action.
2. Click the action to open its settings.&#x20;
3. Define [conditions](#condition-values) to filter the subset of events. \
   For example, use the `Get asset ID` macro to locate a specific file.
4. Add a relevant action to act on the subset of events. This action appears with the <img src="https://3236294211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MesrnyDMZGYg1V-tOBo%2Fuploads%2FtS4NVRcY1t3dYrsSJlfB%2Fadd%20filter.png?alt=media&amp;token=562d19a7-d350-47a9-ad5f-27e62a3c6e19" alt="" data-size="line"> **Filter** icon. \
   For example, Remove public sharing will change the sharing status for this specific subset of assets.
5. Add a **Notify in Slack** action to inform the security team.

After the workflow runs, the public sharing status will be removed from the subset of selected assets.

<figure><img src="https://3236294211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MesrnyDMZGYg1V-tOBo%2Fuploads%2FzbKlnSRYBwwtqULW9xbv%2FEvent%20filter.png?alt=media&amp;token=d504e53d-3863-45c1-91a3-c613a95175ea" alt=""><figcaption><p>Defining an event filter to run on a subset of events</p></figcaption></figure>

## End workflow

You can end a workflow execution as part of the flow logic, and assign one of these statuses:&#x20;

* **Success** - The workflow was completed successfully.&#x20;
* **Warning** - The workflow execution didn’t fail but couldn’t be fully completed due to a non-urgent issue, such as the file or collaborator not being found.

<div align="left"><figure><img src="https://3236294211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MesrnyDMZGYg1V-tOBo%2Fuploads%2FS3BjghNz10Fr2mgcpWOS%2Fend%20workflow.png?alt=media&amp;token=e51c6363-02a9-4f84-8f94-ca2b6aab7eac" alt=""><figcaption><p>End a workflow with a success or warning status</p></figcaption></figure></div>

{% hint style="info" %}
**Use case**: If an HTTP request sent to a third-party system returned an HTTP error code status, you might want to set a warning status and check the response as a result.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.docontrol.io/docontrol-user-guide/workflows/define-workflow-settings/action-settings/flow-control.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
