web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

save user settings

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

You will see I have a tablet application in which I have 2 icons:

 

one of a moon

(dark mode)

 

one of a sun
(Clear mode)

 

I want to save the user configuration since the light mode will be by default but if you choose the dark mode I want that when you re-enter the application continue with the dark mode.

 

It would be great to be able to do it with a formula that I have read from the SaveData formula, but it doesn't work when I apply it maybe I don't apply it well.

If the solution is in a Sharepoint list, I prefer not to apply this.

Categories:
  • eka24 Profile Picture
    20,925 on at
    Create a Table OnStart of Your App (You can also use your Existing Table):
    Set( UserTable7,
    Table({ EmailAddress: "sss@aa.com", Name: "RR", PreferedColor: "ColorBlack"},
    { EmailAddress: "kss@aa.com", Name: "PP", PreferedColor: "ColorBlue" },
    {EmailAddress: "uu@aa.com", Name: "LL7", PreferedColor: "ColorWhite"}
    ))
     
    Then do a Variable OnVisible or Also OnStart of the App to lookup the User
    prefered Color:in:
    Set(VarMyColor,LookUp(UserTable7,EmailAddress=User().Email,PreferedColor))
     
    Finally, in the Fill of the Form or Screen put:
    VarMyColor
     
    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
     
  • Verified answer
    mdevaney Profile Picture
    29,993 Moderator on at

    @Anonymous 

    My method will save the DarkMode settings to the device.

     

    Put this code in the OnSelect property of your Moon icon 

     

    ClearCollect(colUserSettings, {DarkMode: true});
    SaveData(colUserSettings, "UserSettings");

     

    Then, put this code in the OnSelect property of your Sun icon.

     

    ClearCollect(colUserSettings, {DarkMode: false});
    SaveData(colUserSettings, "UserSettings");

     

    Finally, use this code in the app OnStart property.

     

    LoadData(colUserSettings, "UserSettings");
    Set(isDarkMode, LookUp(colUserSettings, First(colUserSettings).DarkMode);

     

    Now you can check for DarkMode at any time by using the variable

     

    isDarkMode

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @mdevaney  

     

    thanks for answering I have applied what you indicated,

    how can i use this in the fill property of controls.

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    hi @mdevaney 

     

    it gives me the following error telling me that it cannot save data in the web browser

  • mdevaney Profile Picture
    29,993 Moderator on at

    @Anonymous 
    You can't save data in a web-browser.  SaveData and LoadData only work on a mobile device like a tablet.  I assumed this was OK because your question said you were making a tablet app.

     

    There is no work-around for a PC/Laptop.  You must save this info to a datasource like SharePoint.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @Anonymous

    You can use it in the Fill property like this

    If(isDarkMode=true, Black, White)

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • OBN Profile Picture
    3 on at

    I followed you entire solution, but it didn't work. Don't have a clue why.

    On the web interface I got errors saying that "Name isn't valid. This identifier isn't recognized".

    Perhaps it's because the web interface can't save files (know this), so it can't run the app, and thus - don't recognize the variables?

    And perhaps I'm not checking isDarkMode correctly, either of these work:

    If( isDarkMode:True, "Darkmode!", "WhiteMode")

    If( isDarkMode=True, "Darkmode!", "WhiteMode")

    If( isDarkMode = "True", "Darkmode!", "WhiteMode")

     

    BTW, I'm trying to save user's preferences about language and interface.

     

  • JimmyW Profile Picture
    2,567 on at

    Stumble upon this old post, great solution @mdevaney 

    Can use this example if i have multiple toogles?
    Lets say i have one for Dark Mode and one for Compact mode.
    I cannot use clearcollect as it will erase the other setting, i tried to use patch to update the table but not successfully.

    I have two toggle switches as i described how do i update the collection value when i toggle?

  • JimmyW Profile Picture
    2,567 on at

    Did it like this:

    Set(var3, true);
    ClearCollect(colUserSettings,
    {TicketID: var1},
    {DarkMode: var2},
    {CompactMode: var3}
    );
    SaveData(colUserSettings, "UserSettings");

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard