# Adding & managing flow variables

## Introduction

Flow variables are added and managed for any process flow via [process flow settings](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-settings). Once variables are defined, they can be referenced throughout the system - for example, in [scripts](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables/referencing-flow-variables-in-custom-scripts), or as [variable values](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/referencing-flow-variables-in-a-process-flow#introduction).

## Adding flow variables

**Step 1**\
[Access the required process flow](https://doc.wearepatchworks.com/product-documentation/process-flows/accessing-your-process-flows).

**Step 2**\
Select the 'settings' icon from the [actions bar](https://doc.wearepatchworks.com/product-documentation/process-flows/the-process-flow-canvas#the-actions-bar):

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Ftu7JBoN9wyi3nU3nRlqw%2Fflow%20variables%201.png?alt=media&#x26;token=b4c56ff4-6bdd-4e94-8775-68469569dba7" alt=""><figcaption></figcaption></figure>

**Step 3**\
Scroll down the settings drawer to the **variables** section, then click the **add new flow variable** button:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F1TFApgy75g3KYcfHk3Lm%2Fflow%20variables%202.png?alt=media&#x26;token=a977ba31-54f5-4a43-9b84-6673857c9ad0" alt=""><figcaption></figcaption></figure>

**Step 4**\
Enter a name for this variable - the name you enter here should be specified whenever you are referencing this variable:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fyxsxnh5EoshiaWcBOeZE%2Fflow%20variables%204b.png?alt=media&#x26;token=21232a87-60be-493d-9cdf-99766a3ca57e" alt=""><figcaption></figcaption></figure>

**Step 5**\
Click the **select a type** field and choose the required type:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FHhAvwgtM5WRTyK8EgzZI%2Fflow%20variables%204.png?alt=media&#x26;token=8ca608de-1f7e-46ea-bc82-c4a20884bd7b" alt=""><figcaption></figcaption></figure>

The following options are available:

<table><thead><tr><th width="224">Variable type</th><th>Variable is defined and passed as...</th></tr></thead><tbody><tr><td>String</td><td>A string value.</td></tr><tr><td>Number</td><td>A numeric value.</td></tr><tr><td>Specific date</td><td>A selected date - choose the required date/time from a date picker.</td></tr><tr><td>Dynamic date</td><td>A <code>+</code>/<code>-</code> number of <code>seconds</code>, <code>minutes</code>, <code>hours</code>, <code>days</code>, <code>months</code>, <code>years</code> to be matched relative to the current date. You can also specify a time zone and the required date format.</td></tr><tr><td>Boolean</td><td>A true/false value.</td></tr></tbody></table>

**Step 6**\
Enter the required value for this variable and save settings:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F0GJlrFtR2wCWWxqW4DOr%2Fflow%20variable%20-%20add%20-%203.png?alt=media&#x26;token=f2583d76-97c2-41af-9034-84afed938e1b" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
When a variable is marked as `secret`, it will never be displayed on this page. However, it may be shown in [run logs](https://doc.wearepatchworks.com/product-documentation/process-flows/error-reporting-and-exception-handling/run-logs-and-queue) and (if used as a [dynamic variable](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables)) in [cache keys](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape).
{% endhint %}

**Step 7**\
If you want to hide this value from being displayed after the variable is saved, toggle ON the `is this variable a secret?` option:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FxJH4X9vbhPGRejpad2p3%2Fflow%20variable%20-%20add%20-%204.png?alt=media&#x26;token=a57fe0db-2692-4b6a-a24a-767263e17d28" alt=""><figcaption></figcaption></figure>

**Step 8**\
Save settings.

## Updating flow variables

**Step 1**\
Access settings for the required process flow, as detailed [above](#adding-flow-variables).

**Step 2**\
Click the 'edit' icon associated with the variable you want to change:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FgxyWDOdTpPzZs3X8eiL7%2Fedit%20flow%20variable%201.png?alt=media&#x26;token=47837585-4b38-4eb6-9a65-501156a3aa96" alt=""><figcaption></figcaption></figure>

**Step 3**\
Now you can either update existing settings and click the **update** button, or click the **delete** button to remove this variable:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FiM88okiCENL9oIMTDyWs%2Fupdate%20flow%20variable%201a.png?alt=media&#x26;token=e1edd784-410a-4b9a-9d91-decb0c91be04" alt=""><figcaption></figcaption></figure>
