Custom States and Usage

Please treat me like a Newby when answering this question.

How would I make use of a custom state. Not only save something as a custom state but then actually use what I saved?

I am completely at loss when it comes to custom states but know that they would be a powerful addition to my programming skills.

Thanks in advance for any help.

Please keep it as simple and step by step as possible. Otherwise I am bound to get lost.

1 Like

Here is a tutorial which shows how to use custom states to make a text box hide/show. It also makes the button appear to be “on” when activated.

2 Likes

Here’s an example I’ve used:

When Page is loaded -> Set index’s custom state: ‘step’ to 0

Then for hidden Group A, conditional when index’s step is 0, Group A is visible

Then for Button A in Group A, when clicked set index’s ‘step’ to 1

Then for hidden Group B, conditional when index’s step is 1, Group B is visible

2 Likes

@cakeheke Why would you use custom states in workflow, rather than a conditional in the design side?

You can also have a look at the Tab Element template. See how they did it and play around with your ideas. That’s how I learned it.

Almost similar to the Tab Element template

Workflow states are when Custom States can get very useful, but also quite complex.

If you remember the “list of fruits” example we did a while ago, that had a temporary list of items that could be selected/deselected … that is all workflow custom state based. You are changing a list held in a custom state based on actions.

1 Like

This was very helpful. Can you give me some usage cases where a custom state would be used as opposed to setting a condition? Trying to get my mind inspired on how I can use these in my apps…

1 Like

Yes please… We’re not using states at all, and I’m sure we should be!!

I use both.

But the ultimate reason for me to use custom states in a workflow setup, is so that the custom state can perform other functions at the same time.

For example, if I want a button to change color when latched (conditional), AND also to change an item in my database when latched (non-conditional), then I would use a custom state in a ‘workflow’ setup.

If you want it so the button can keep it’s current state for the next time the user logs in, then you would need to use a flag/state in your database. For this i usually create a new field called ‘flags’ as a yes/no type.

1 Like

Yes, so …

Element States

As above, is a button pressed
What tab is visible in this group

Page States

Is the page in edit mode or view mode.
If it is a mobile app what “page” is it on (native mobile apps only have a single page)

Temporary Data

Counts of actions
Temporary lists - so multiple selections
Data transformation

6 Likes