32
Views
7
Comments
How to Retain Switch State After Screen Refresh

I am working on a two-state toggle switch using a static value. I want the switch state to persist even after the screen is refreshed. Currently, when I refresh the screen, the switch state resets automatically.

My goal is:

  • If the user sets the switch to true, it should remain true even after a page reload.
  • The state should be retained until the user manually changes it.

I would like to know the best approach for this ?

I am attaching the OML file for your reference.


Switch.oml
2026-01-28 16-57-48
Mihai Melencu
Champion

Hello,


You can replace your variable used in the switch with a client variable .

I updated your OML.

Switch_updated.oml
2025-01-23 09-22-22
ABHIJITH G
Champion

Hi @Dinesh Murugan ,
Instead of using a local variable to store the Switch state use a client variable. 

Thanks

2022-12-30 07-28-09
Navneet Garg

you need to store switch state either in client variable or in the database.

client variable is work for you if you are not closing the browser.

but if you want to persist the state of switch even if user close the browser that save state in database and fetch it when screen loads.

2026-02-16 05-51-10
Sahana K

Hi ,
Create a Client Variable

  1. Go to Data → Client Variables.
  2. Create a new Client Variable
    Reason:
    Client Variables are stored in Local Storage, meaning the toggle state remains even after the user refreshes the page
    If you use a normal screen variable, the value will reset after a refresh.

    Thanks,
    Sahana

2023-11-22 10-51-50
Jozy Sohail

Hi,

As everyone suggested, use the client variables to store the state of your switch as they are stored locally, they make the app faster and smoother, even if the user navigates between screens or refreshes the page. 

Attaching the OML for your reference.

Hope it helps.

Switch.oml
2026-01-23 11-38-55
Dinesh Murugan
Champion

Hi all ,


Really thanks for your replies.


I am working on a two-state toggle switch using a static entity with the record of IsEnable. Once the switch is changed (either true or false), I want it to remain the same for all users.

The state should persist even after a page reload

 The goal is for the switch to remain true if the user sets it to true, even after a page reload. The state should be retained until the user manually changes it, and the value want to use in the app 2 as well.

2023-11-22 10-51-50
Jozy Sohail

Hi Dinesh,

create an entity and store the value of client variable in that entity and use that entity in your other app.

hope it helps,

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.