---
description: >-
  This article helps with basic navigation of the Folders functionality of
  Decision Rules
---

# Folders

{% embed url="https://www.youtube.com/watch?t=21s&v=0L0YsddlEUs" %}

### Navigating Folders

Clicking the <img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2Fqa9zMVisNjKGOA3aKbCy%2Fimage.png?alt=media&#x26;token=f7f4f2b0-fcfa-427d-9ac3-a6a331925877" alt="" data-size="line"> button in the app sidebar opens the Folders menu.

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2F4KttdejgkHDHX3eVsQiS%2Fimage.png?alt=media&#x26;token=102b9d1a-d4e0-43da-aef9-0bf4c07a3e1e" alt=""><figcaption></figcaption></figure>

Clicking on a Folder selects it and displays the contents on the screen.

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FSlPLFWSvvV5ADfZpIafl%2Fimage.png?alt=media&#x26;token=7d5bc0c3-da20-4f4a-acd0-b432b66e24a5" alt=""><figcaption><p>Secret Folder contains only one rule - Tall Tree, therefore only Tall Tree is displayed in the overview </p></figcaption></figure>

### Folders overview screen controls bar

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2F4pkJ1rOnzHfj507c42aH%2Fimage.png?alt=media&#x26;token=4dcd0ad3-7ccf-4383-b2b8-da8bd069452c" alt=""><figcaption></figcaption></figure>

The **View**, **Filter** and **Sort by** selectors help us manage which rules we'd like to display.

The **View** selector lets us choose whether to display only the rules inside our selected Folder or all rules across the entire Space we're currently in.

Using the **Filter** selector, we can define the types of rules to be displayed.

Lastly, the **Sort by** selector controls the ordering of the displayed rules.&#x20;

* Name - Sorts rules in an alphabetical order by name
* Time - Sorts rules from the latest updated rule to the oldest.
* Default - Sorts rules as they appear in the Folder manager.

{% hint style="info" %}
The controls bar also lets us create new Rules inside the current Folder or import existing Rules into it.
{% endhint %}

### Folders tree controls

#### At the top of the Folders manager you can find four controls icons.

1. The ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2F1ZmHZlmVZSWryG80f5OX%2Fimage.png?alt=media\&token=f2cb02d4-5cb5-47bd-8f06-9ba8c476e704)/![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FZ7Kb8FaoYlPvtdo17Mwv%2Fimage.png?alt=media\&token=2eec54ac-206b-4d07-a402-492a9243d97e) Icon Expands/Collapses the Folder structure i.e. Opens/Closes all Folders.
2. The ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FHGhAFo6EMg2ApsahxgMr%2Fimage.png?alt=media\&token=5cae6ac9-9a3b-4d40-aa8e-aadebcb53e75) Icon creates a new Folder.
3. The ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2F4sgxPPazHQkp4oFh1Hn6%2Fimage.png?alt=media\&token=3b1ea5b0-0909-4082-a396-345359746f91) Icon refreshes the Folder tree incase you want to be sure everything is up to date.
4. The ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2F6FWwcDSF4decPweaQGJO%2FScreenshot%202023-07-19%20at%2015.28.16.png?alt=media\&token=2324fa2b-73c6-48f5-a8d3-04eff69e8be5) Icon allows you to filter by rule state (published/unpublished)
5. And finally the ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2Fq4kIwTRmcqgMq9nUvUmf%2Fimage.png?alt=media\&token=46956128-4aca-4b1b-b7d6-8a7bae135f05) Icon closes the Folder manager.

#### Right-clicking the items

Right-clicking on Rules and Folders in the Folder manager brings up different context menus.

The context menu for a Rule: ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FcOLJggS2UfHoXvXl1UUo%2Fimage.png?alt=media\&token=4527d852-e452-45cd-bdb4-536658ac25ec)

The context menu for a File:  ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FOvNZ9GVRrp78Mwb6n1ZU%2Fimage.png?alt=media\&token=6661bc56-2d01-4876-a9b6-1579968fe8d0)

{% hint style="info" %}
The ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FCB4rDEk2i5Agf0MP3Rmi%2Fimage.png?alt=media\&token=7ecaa012-7709-4d2a-a114-bb5f9985c67f) Folder works the same as all other Folders except you can't Rename it, Clone it nor Delete it.
{% endhint %}

#### The Search functionality

Underneath the Folders header is a Search input field. Entering characters then filters your rules to show only the ones containing your input.

![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FUSVdBckOew9sKyVnGM4W%2Fimage.png?alt=media\&token=976b5c7b-4074-45d9-8eba-971138f3c73e) -> ![](https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FdC9kTME2GTZTuKziWWzr%2Fimage.png?alt=media\&token=a484ab65-b59d-4ac9-a771-31f876191d00)

### Export Folder

Clicking on the "**Export folder**" option in the context menu allows you to initiate the process of exporting the selected folder and its contents to **JSON** format.

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FVEh7vG1nO6WVarjVrCkN%2FScreenshot%20from%202023-08-02%2013-55-16.png?alt=media&#x26;token=81a47ba8-3361-4714-9707-10c79b4a1f37" alt=""><figcaption><p>Folder context menu</p></figcaption></figure>

<details>

<summary>Export example</summary>

```
{
    "export": {
        "exportType": "FOLDER",
        "version": 1,
        "createdAt": "2023-08-02T10:13:03.825Z",
        "data": {
            "structure": {
                "id": "f600f63a-2281-669a-9aa6-1aa3110ccc26",
                "name": "Test Import",
                "type": "FOLDER",
                "children": [
                    {
                        "baseId": "595e7659-641d-8200-ba42-40b683ca1c5c",
                        "type": "RULE",
                        "version": 1
                    },
                    {
                        "baseId": "6fb875d8-5e1a-4139-7d47-c22fea912c0b",
                        "type": "RULE",
                        "version": 1
                    }
                ]
            },
            "rules": [
                {
                    "name": "Scripting rule 2",
                    "description": "Sample scripting rule",
                    "inputSchema": {
                        "value1": {},
                        "value2": {}
                    },
                    "outputSchema": {
                        "result": {}
                    },
                    "script": "/* \n    1.  Input variables\n    Input body is set in input variable \n*/\nlet a = input.value1;\nlet b = input.value2;\n\n/*\n    2.  Define simple \"multiply\" function\n*/\nfunction multiply(a, b) {\n    return a * b;\n}\n\n/*\n    3.  Execute multiply function and store value result variable\n*/\nlet resultMultiply = multiply(a, b);\n\n/*\n    4.  Set output model which is returned in REST API\n*/\noutput.result = resultMultiply;\n\n/*\n    Optionally: It is possible print values to console\n*/\nlog('Result multiply:', resultMultiply);\n\n/*\n    5.  Return output  \n*/\nreturn output;",
                    "type": "complex-rule",
                    "status": "published",
                    "auditLog": {
                        "active": false,
                        "debug": {
                            "active": false
                        },
                        "ttl": 14
                    },
                    "ruleId": "595e7659-641d-8200-ba42-40b683ca1c5c",
                    "baseId": "595e7659-641d-8200-ba42-40b683ca1c5c",
                    "version": 1,
                    "ruleAlias": "specific-roadrunner",
                    "createdIn": "2023-08-02T08:12:56.738Z",
                    "lastUpdate": "2023-08-02T08:12:56.738Z",
                    "tags": []
                },
                {
                    "name": "Scripting rule 1",
                    "description": "Sample scripting rule",
                    "inputSchema": {
                        "value1": {},
                        "value2": {}
                    },
                    "outputSchema": {
                        "result": {}
                    },
                    "script": "/* \n    1.  Input variables\n    Input body is set in input variable \n*/\nlet a = input.value1;\nlet b = input.value2;\n\n/*\n    2.  Define simple \"multiply\" function\n*/\nfunction multiply(a, b) {\n    return a * b;\n}\n\n/*\n    3.  Execute multiply function and store value result variable\n*/\nlet resultMultiply = multiply(a, b);\n\n/*\n    4.  Set output model which is returned in REST API\n*/\noutput.result = resultMultiply;\n\n/*\n    Optionally: It is possible print values to console\n*/\nlog('Result multiply:', resultMultiply);\n\n/*\n    5.  Return output  \n*/\nreturn output;",
                    "type": "complex-rule",
                    "status": "published",
                    "auditLog": {
                        "active": false,
                        "debug": {
                            "active": false
                        },
                        "ttl": 14
                    },
                    "ruleId": "6fb875d8-5e1a-4139-7d47-c22fea912c0b",
                    "baseId": "6fb875d8-5e1a-4139-7d47-c22fea912c0b",
                    "version": 1,
                    "ruleAlias": "interested-mackerel",
                    "createdIn": "2023-08-02T08:12:42.965Z",
                    "lastUpdate": "2023-08-02T08:12:42.965Z",
                    "tags": []
                }
            ]
        }
    }
}
```

</details>

#### Warning dialog

Folder to export contains rules that have connections or dependencies with other rules located outside of the export folder. Such dependencies might be crucial for the proper functioning of the rules, and exporting the folder without considering these dependencies could lead to errors or issues.

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2F8FVcTU8yxiu7WGQmZHtk%2FScreenshot%20from%202023-08-02%2014-10-58.png?alt=media&#x26;token=6fb14fc9-823b-4c0b-89da-f031ee804a2e" alt=""><figcaption><p>Export Warning dialog</p></figcaption></figure>

#### Possible errors

* **Rule not in folder -** exported rule has a dependency outside of the exported folder &#x20;
* **Rule not found -** rule with the identifier (id, alias) was not found
* **Duplicity id / alias -** more rules with the same identifier (id, alias) &#x20;

{% hint style="warning" %}
Rule dependencies won't be found when rules point to each other dynamically (e.g., using for loop).
{% endhint %}

### Import Folder

Clicking on the "**Import**" option in the context menu allows you to initiate the process of importing folder into the selected folder. The expected format of the file to import is **JSON.**

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FbjUGfermTPOPuZeFLhPZ%2FScreenshot%20from%202023-08-02%2014-16-19.png?alt=media&#x26;token=6fde1b48-b6ec-496a-94bc-83de8b5eb09e" alt=""><figcaption><p>Folder context menu</p></figcaption></figure>

{% hint style="warning" %}
When importing a folder, it may take a bit longer to process. The duration of the import process can vary depending on the number of rules and subfolders in the folder.
{% endhint %}

<details>

<summary>Import Example</summary>

```
{
    "export": {
        "exportType": "FOLDER",
        "version": 1,
        "createdAt": "2023-08-02T10:13:03.825Z",
        "data": {
            "structure": {
                "id": "f600f63a-2281-669a-9aa6-1aa3110ccc26",
                "name": "Test Import",
                "type": "FOLDER",
                "children": [
                    {
                        "baseId": "595e7659-641d-8200-ba42-40b683ca1c5c",
                        "type": "RULE",
                        "version": 1
                    },
                    {
                        "baseId": "6fb875d8-5e1a-4139-7d47-c22fea912c0b",
                        "type": "RULE",
                        "version": 1
                    }
                ]
            },
            "rules": [
                {
                    "name": "Scripting rule 2",
                    "description": "Sample scripting rule",
                    "inputSchema": {
                        "value1": {},
                        "value2": {}
                    },
                    "outputSchema": {
                        "result": {}
                    },
                    "script": "/* \n    1.  Input variables\n    Input body is set in input variable \n*/\nlet a = input.value1;\nlet b = input.value2;\n\n/*\n    2.  Define simple \"multiply\" function\n*/\nfunction multiply(a, b) {\n    return a * b;\n}\n\n/*\n    3.  Execute multiply function and store value result variable\n*/\nlet resultMultiply = multiply(a, b);\n\n/*\n    4.  Set output model which is returned in REST API\n*/\noutput.result = resultMultiply;\n\n/*\n    Optionally: It is possible print values to console\n*/\nlog('Result multiply:', resultMultiply);\n\n/*\n    5.  Return output  \n*/\nreturn output;",
                    "type": "complex-rule",
                    "status": "published",
                    "auditLog": {
                        "active": false,
                        "debug": {
                            "active": false
                        },
                        "ttl": 14
                    },
                    "ruleId": "595e7659-641d-8200-ba42-40b683ca1c5c",
                    "baseId": "595e7659-641d-8200-ba42-40b683ca1c5c",
                    "version": 1,
                    "ruleAlias": "specific-roadrunner",
                    "createdIn": "2023-08-02T08:12:56.738Z",
                    "lastUpdate": "2023-08-02T08:12:56.738Z",
                    "tags": []
                },
                {
                    "name": "Scripting rule 1",
                    "description": "Sample scripting rule",
                    "inputSchema": {
                        "value1": {},
                        "value2": {}
                    },
                    "outputSchema": {
                        "result": {}
                    },
                    "script": "/* \n    1.  Input variables\n    Input body is set in input variable \n*/\nlet a = input.value1;\nlet b = input.value2;\n\n/*\n    2.  Define simple \"multiply\" function\n*/\nfunction multiply(a, b) {\n    return a * b;\n}\n\n/*\n    3.  Execute multiply function and store value result variable\n*/\nlet resultMultiply = multiply(a, b);\n\n/*\n    4.  Set output model which is returned in REST API\n*/\noutput.result = resultMultiply;\n\n/*\n    Optionally: It is possible print values to console\n*/\nlog('Result multiply:', resultMultiply);\n\n/*\n    5.  Return output  \n*/\nreturn output;",
                    "type": "complex-rule",
                    "status": "published",
                    "auditLog": {
                        "active": false,
                        "debug": {
                            "active": false
                        },
                        "ttl": 14
                    },
                    "ruleId": "6fb875d8-5e1a-4139-7d47-c22fea912c0b",
                    "baseId": "6fb875d8-5e1a-4139-7d47-c22fea912c0b",
                    "version": 1,
                    "ruleAlias": "interested-mackerel",
                    "createdIn": "2023-08-02T08:12:42.965Z",
                    "lastUpdate": "2023-08-02T08:12:42.965Z",
                    "tags": []
                }
            ]
        }
    }
}
```

</details>

{% hint style="info" %}
The imported rules and folders will be assigned with new unique IDs. However, the dependencies between the rules will remain the same.
{% endhint %}
