Switch button

Once I refresh the page the switch buttons which are in listview should be true after that It should allow us to make false and can save as well Again Once we refresh the page again all the button should be true except the one which i made false in previous refresh
1 answers

Hi Sachin,


1. Create an entity called "SwitchButton" with attributes "ButtonState" (Boolean) and "ButtonIdentifier" (String).

2. Use a ListView to display the list of switch buttons on your page and bind the "ButtonState" attribute to the switch button.

3. Create a microflow to retrieve all "SwitchButton" entities and use it as the data source for the ListView.

4. Add an OnClick event to the switch button widget. In the microflow triggered by the OnClick event, toggle the "ButtonState" attribute (True to False or vice versa) of the clicked "SwitchButton" entity and save the changes.

5. Create another entity called "UserSettings" with an attribute "LastChangedButtonIdentifier" (String). Modify the microflow (from step 4) to also update the "LastChangedButtonIdentifier" attribute in the "UserSettings" entity with the identifier of the last clicked "SwitchButton" entity. Then, modify the microflow to set the "ButtonState" attribute to True for all "SwitchButton" entities except the one identified in the "UserSettings" entity.

Now, the switch buttons' states will be loaded as True after refreshing the page.