# Custom States

A custom state is an arbitrary container capable of holding any type of data (single or list) that is readily available to the user in the current browser session.

{% hint style="warning" %}
It doesn't matter where you create the custom state (or how), as long as you keep in mind that when you add it inside a cell of a repeating group or inside a reusable element, you cannot access it through a normal 'set state' action.
{% endhint %}

Custom states have two major use cases:

* Storing temporary data on the page
* Navigation

{% hint style="danger" %}
Remember Custom states will not store the data you have saved if you reload the page. &#x20;
{% endhint %}

### Storing data on your page temporarily

In the example below, based on the pre-build admin page that you will find in the template, we want to select multiple users in a list and perform a bulk action on those selected users.

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

When the user clicks the checkbox for selecting a user in the table, we add this user to our custom state list of users which we created previously.

<figure><img src="/files/MR181Auw0OF3LZYkcXG7" alt=""><figcaption><p>We selected 3 users from the table. All of them are added to the Custom state list.</p></figcaption></figure>

We can then send the list of users from the ⚡️selectedUsers to the backend workflows to delete them.&#x20;

{% hint style="warning" %}
Make sure that the custom state is of the type you want to work with and the 'is a list' checkbox is checked.&#x20;
{% endhint %}

<figure><img src="/files/H9zGzA0c9NXRcursofDC" alt=""><figcaption><p>Using list &#x26; states in action</p></figcaption></figure>

### Working with pre-loaded data

If you work with set of data that has be pre-loaded on a page it's better to use Repeating Group element rather than a custom state as a list.

For example imaging we have a field called ' Permissions' on the User data type. If you would like to  display list of Permission on page load for that User via state would have to set that values on the page load since you cannot set default values of a state if it's a list or custom datatype.

If you have more then one custom state list or custom state field where data needs to always be available on page load, the 'Page is loaded' can quickly become bulky with 'Set state' action, especially if you have multiple elements where you want to set the state.

<figure><img src="/files/9vsgW2YkiOy8uHNH3m3P" alt=""><figcaption><p>Setting default state on page load</p></figcaption></figure>

It's much better to work with repeating groups when it comes to lists. On the page load, you do not have to worry about setting the state of the list as it will automatically pre-populate since it's a repeating group. You can structure your repeating groups in the [Source popup](/working-with-the-framework/data-and-workflows/source-popup.md) or use the Repeating group in which you display the data.

<figure><img src="/files/Vvd40lIgtrwWmXTzS4vH" alt=""><figcaption><p>Repeating group storing permissions of the User</p></figcaption></figure>

Additionally manipulating the list in the Repeating group is as easy as manipulating the custom state with the 'Display list in a repeating group' action.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.openbuild.io/working-with-the-framework/data-and-workflows/custom-states.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
