> For the complete documentation index, see [llms.txt](https://docs.rapidbott.com/help-center/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rapidbott.com/help-center/flow-builder/steps/variable-operation.md).

# Variable Operation

Built-in operations for variable modification.

There are 6 types of variable:

<table><thead><tr><th width="145">Type</th><th>Storage</th><th>Example</th><th>Operation</th></tr></thead><tbody><tr><td>Text</td><td>letters, words, sentences...</td><td>Hi, Rapidbott.</td><td>cutting, change case, encode, decode...</td></tr><tr><td>Number</td><td>number</td><td>123.45</td><td>+ - x ÷, mod, power, log, root, round...</td></tr><tr><td>Boolean</td><td>either "yes" or "no"</td><td>yes</td><td>assign</td></tr><tr><td>Date</td><td>date</td><td>2021-03-30</td><td>format, add months/weeks/days</td></tr><tr><td>DateTime</td><td>date and time</td><td>2021-03-30 16:52:00</td><td>format, add months/weeks/days/hours/minutes</td></tr><tr><td>JSON</td><td>a series of variables</td><td>{"name":"jack", "age":"10"}</td><td>load, get, update, remove, count, sum, average, sort, shuffle, reverse...</td></tr></tbody></table>

Click "Basic Actions" in the Action step and here are the "Set Variable Value" and "Clear Variable Value".

<figure><img src="/files/XtWYTPMW54cpt9EXjSws" alt=""><figcaption></figcaption></figure>

### Clear Custom Field / Clear JSON <a href="#clear-custom-field-clear-json" id="clear-custom-field-clear-json"></a>

To clear text, number, boolean, date, datetime variable, please use the **Clear Custom Field** action.

To clear JSON variable, please use the **Remove All Items** operation in the [**JSON Operation**](broken://pages/9xMP1tqNK8ZQGsKKAgnI).

### Clear Variable Value <a href="#clear-variable-value" id="clear-variable-value"></a>

This function allows the user to literally clear a value of a single custom field.

<figure><img src="/files/LUaX3keYH0g6o8bjGHYG" alt=""><figcaption></figcaption></figure>

You just have to choose a specific custom field you want to clear out.

### Clear Multiple Variable Value <a href="#clear-multiple-variable-value" id="clear-multiple-variable-value"></a>

This action allows the user to clear multiple custom field values.

<figure><img src="/files/2cdE8B4vt0QYDw342tbf" alt=""><figcaption></figcaption></figure>

Make sure to choose all custom fields whose values you want to clear out.

### Clear All Custom User Fields <a href="#clear-all-custom-user-fields" id="clear-all-custom-user-fields"></a>

If you are looking for a way to clear all custom field values of a user, use this action.

<figure><img src="/files/YyTFDMlghsETh8kiDyUc" alt=""><figcaption></figcaption></figure>

### Input value <a href="#input-value" id="input-value"></a>

"input value" operation is used to assign value to a variable. This operation works for any variable type.

{% hint style="info" %}
"input value" for text variable can be used to connect several text variables. See the below picture for where to put original value and operated value.
{% endhint %}

<figure><img src="/files/JFA744xN0l6xOAhm8kak" alt=""><figcaption></figcaption></figure>

### Math Formula <a href="#math-formula" id="math-formula"></a>

![condition](https://i.imgur.com/sHDee6i.png)

With this operation, you can now do formula calculation directly in the Action Step - "Set Variable Value" and Condition Step - "Value".

Math operations and function supported:

+, -, \*, e, pi, PI, abs(), min(), max(), ceil(), floor(), log(), pow(), round(), sqrt(), sin(), cos(), tan()

{% hint style="info" %}
If the formula is invalid, the system will return 0 to number variable and empty to text variable.
{% endhint %}

## &#x20;Set Text Variable <a href="#set-text-variable" id="set-text-variable"></a>

#### Trim text <a href="#trim-text" id="trim-text"></a>

| Description                            | e.g. Before | e.g. After |
| -------------------------------------- | ----------- | ---------- |
| remove spaces before or after the text | " abc "     | "abc"      |

<figure><img src="/files/2GWT9dL0ZCKVTzI0ZPbT" alt=""><figcaption></figcaption></figure>

### Sub string <a href="#sub-string" id="sub-string"></a>

| Description          | e.g. Before   | e.g. After |
| -------------------- | ------------- | ---------- |
| get part of the text | "Hi, Sendly!" | "Sendly"   |

<figure><img src="/files/pJkzGBitIEV6DtXLjo7g" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Index starts from 0. Every character counts including space and punctuation.
{% endhint %}

### Replace string / replace string case sensitive <a href="#replace-string-replace-string-case-sensitive" id="replace-string-replace-string-case-sensitive"></a>

| Description              | e.g. Before      | e.g. After          |
| ------------------------ | ---------------- | ------------------- |
| replace part of the text | "Hi, Rapidbott!" | "Hello, Rapidbott!" |

<figure><img src="/files/MPSNrmHR6ziJPUr17jw9" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
In case sensitive situation, you have to put exactly "Hi" rather than "hi", "HI" or "hI".
{% endhint %}

### To lower / upper case <a href="#to-lower-upper-case" id="to-lower-upper-case"></a>

| Type          | e.g. Before      | e.g. After       |
| ------------- | ---------------- | ---------------- |
| to lower case | "Hi, Rapidbott!" | "hi, rapidbott!" |
| to upper case | "Hi, Rapidbott!" | "HI, RAPIDBOTT!" |

<figure><img src="/files/nv7BJwzIndzU4XNmoLv6" alt=""><figcaption></figcaption></figure>

### Generate random text <a href="#generate-random-text" id="generate-random-text"></a>

| Description | e.g. Before            | e.g. After             |
| ----------- | ---------------------- | ---------------------- |
| as the name | "code: XXXX-####-xxxx" | "code: UBWT-3657-lkzb" |

<figure><img src="/files/vo88mD5vYi26SneuatuV" alt=""><figcaption></figcaption></figure>

This feature is useful when you need to generate one-time verification code or reference code.

### url encode / decode <a href="#url-encode-decode" id="url-encode-decode"></a>

| Type   | e.g. Before          | e.g. After           |
| ------ | -------------------- | -------------------- |
| encode | "Hi, Rapidbott!"     | "Hi%2C%20Rapidbott!" |
| decode | "Hi%2C%20Rapidbott!" | "Hi, Rapidbott!"     |

<figure><img src="/files/xc9BaRebvyOscgTImZfD" alt=""><figcaption></figcaption></figure>

### Base64 encode / decode <a href="#base64-encode-decode" id="base64-encode-decode"></a>

| Description | e.g. Before        | e.g. After         |
| ----------- | ------------------ | ------------------ |
| encode      | "Hi, Sendly!"      | "SGksIFVDaGF0IQ==" |
| decode      | "SGksIFVDaGF0IQ==" | "Hi, Sendly!"      |

<figure><img src="/files/FyP3k3fM1VAXMXMZfu01" alt=""><figcaption></figcaption></figure>

### To URL friendly slug <a href="#to-url-friendly-slug" id="to-url-friendly-slug"></a>

| Description                                           | e.g. Before       | e.g. After       |
| ----------------------------------------------------- | ----------------- | ---------------- |
| replace spaces with hyphens and remove the rest signs | "it's a good day" | "its-a-good-day" |

<figure><img src="/files/aldK2qkPMKRx1Fuf0MKV" alt=""><figcaption></figcaption></figure>

#### Get text before/after ... <a href="#get-text-before-after" id="get-text-before-after"></a>

Description: get part of the text.

| Type                                       | e.g. Before                   | e.g. After              |
| ------------------------------------------ | ----------------------------- | ----------------------- |
| get text before another text               | name: Sendly, city: Melbourne | name                    |
| get text before last occur of another text | name: Sendly, city: Melbourne | name: Sendly, city      |
| get text after another text                | name: Sendly, city: Melbourne | Sendly, city: Melbourne |
| get text after last occur of another text  | name: Sendly, city: Melbourne | Melbourne               |

<figure><img src="/files/vQWdZgJEzEkwyErlByYO" alt=""><figcaption></figcaption></figure>

## Set Number Variable <a href="#set-number-variable" id="set-number-variable"></a>

### Get text length <a href="#get-text-length" id="get-text-length"></a>

| Description | e.g. Before | e.g. After |
| ----------- | ----------- | ---------- |
| as the name | 500.59      | 6          |

<figure><img src="/files/1Iqs0aJa0AlPAAB4drK5" alt=""><figcaption></figcaption></figure>

### Generate random number <a href="#generate-random-number" id="generate-random-number"></a>

| Description | e.g. Before | e.g. After |
| ----------- | ----------- | ---------- |
| as the name | n/a         | 56         |

<figure><img src="/files/XwtqBzyaB2H8mFkqIkQp" alt=""><figcaption></figcaption></figure>

### Add / subtract / multiply / divide / modulus / power / natural logarithm / square root <a href="#add-subtract-multiply-divide-modulus-power-natural-logarithm-square-root" id="add-subtract-multiply-divide-modulus-power-natural-logarithm-square-root"></a>

| Description | e.g. Before | e.g. After |
| ----------- | ----------- | ---------- |
| as the name | 7           | 8          |

<figure><img src="/files/cWcmvCAYT77AV8Yxzis9" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
in "natural logarithm", when you are calculating log2(8) = ? put 8 as "Value" and 2 as "Number".
{% endhint %}

### Round <a href="#round" id="round"></a>

| Description | e.g. Before | e.g. After |
| ----------- | ----------- | ---------- |
| as the name | 7.8693      | 7.87       |

<figure><img src="/files/QNWQ2VwCEYLlsR7MPaCD" alt=""><figcaption></figcaption></figure>

### Floor / ceil <a href="#floor-ceil" id="floor-ceil"></a>

Description: get approximate integer.

| Type  | e.g. Before | e.g. After |
| ----- | ----------- | ---------- |
| floor | 6.55        | 6          |
| ceil  | 6.55        | 7          |

<figure><img src="/files/oS5xOWsdA9XXAPc4qor4" alt=""><figcaption></figcaption></figure>

## Set DateTime Variable <a href="#set-datetime-variable" id="set-datetime-variable"></a>

### From formatted text <a href="#from-formatted-text" id="from-formatted-text"></a>

| Description                            | e.g. Before             | e.g. After          |
| -------------------------------------- | ----------------------- | ------------------- |
| get DataTime value from formatted text | 00:00:00 30th Aug, 2020 | 2020-08-30 00:00:00 |

<figure><img src="/files/RrOPU72yJI6e8Td1qhVJ" alt=""><figcaption></figcaption></figure>

### Add minutes / hours / days / weeks / months <a href="#add-minutes-hours-days-weeks-months" id="add-minutes-hours-days-weeks-months"></a>

| Description | e.g. Before         | e.g. After          |
| ----------- | ------------------- | ------------------- |
| as the name | 2021-01-01 00:00:00 | 2021-01-01 00:01:00 |

<figure><img src="/files/ps4dTTFJv1xXxKUdXspJ" alt=""><figcaption></figcaption></figure>
