Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Retain Exit Settings for Next OnStart

(0) ShareShare
ReportReport
Posted on by 5,071 Super User 2025 Season 1

I have a main screen that has a series of buttons that allow for users to navigate through the app.

 

I have a toggle (Toggle1). I use the toggle to shutdown access to the site through the buttons referenced above.

 

The default setting of Toggle1 is 'true'. If for some reason the owner wants to limit access to the site for a period of time the owner can set Toggle1 to 'true' and all of the site buttons will default to 'Disabled'.

 

My issue, if the owner sets Toggle1 to off and then exits the site, when the owner returns the Toggle has reset to 'false' and all the button are back to 'Edit'.

 

How do I set it up so that the setting of Toggle1 is how the site open during the next viewing?

Categories:
  • Verified answer
    BCLS776 Profile Picture
    8,988 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    I'm not quite sure I understand where you are going with this question: You should ensure all necessary columns are present in your list and make sure there are values present (or your app knows how to handle the case with no values). A LookUp will return blank if it finds no matching record.

     

    If you want to pull any value from this list, one way is with First():

    First('Site Startup List').SiteStatus

    This pulls up the value in the SiteStatus column from the first record in the list.

     

  • Phineas Profile Picture
    5,071 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    Right now the Toggle1 default property is 'true'.

     

    How do I write the Lookup in the 'OnStart' to make it pull in the current content of the column in the List? The only column in the List is 'SiteStatus', with the content of 'true' (by default).

     

         Set(Toggle1Default, Lookup('Site Start Up List',...)

  • BCLS776 Profile Picture
    8,988 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    @Phineas wrote:

     

    So, I need to create a List that has a column that stores the default/Patch setting of Toggle1, yes?

     

    Yes, that's correct.

     


    @Phineas wrote:

     

    I should place the Patch command in the 'OnChange' property of Toggle1, yes?

     

    Yes, that would be a good place to put it.

     


    @Phineas wrote:

     

    I should place a condition in the 'OnStart' of the app, yes? The list I will create for this won't have anyone name in it to match. Whatelse should/can I use in the condition. The list will have one row with one column 'ToggleStatus', set to default in SharePoint to 'true', with the Patch changing it back and forth between 'true/false'.

         Set(Toggle1, LookUp(ComplianceList, FullName = User().FullName).Toggle1);

     


    You have a couple of choices here:

    1. You can pre-populate your list with values, or
    2. You can modify your OnStart code to check to see if a LookUp for that user returns a valid value, and if not you set the variable to a preselected default value

     

  • Phineas Profile Picture
    5,071 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    Okay, its starting make a little sense. 😂

     

    So, I need to create a List that has a column that stores the default/Patch setting of Toggle1, yes?

     

    I should place the Patch command in the 'OnChange' property of Toggle1, yes?

     

    I should place a condition in the 'OnStart' of the app, yes? The list I will create for this won't have anyone name in it to match. Whatelse should/can I use in the condition. The list will have one row with one column 'ToggleStatus', set to default in SharePoint to 'true', with the Patch changing it back and forth between 'true/false'.

         Set(Toggle1, LookUp(ComplianceList, FullName = User().FullName).Toggle1);

     

  • BCLS776 Profile Picture
    8,988 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    @Phineas wrote:

    Ok, I've changed the condition to include only fields/columns in my lists.

     

    Set(varVisible, LookUp(ComplianceList, FullName = User().FullName).varVisible); 

         - This looks for the default setting on the list, yes?

     

    Set(Toggle1, LookUp(ComplianceList, FullName = User().FullName).Toggle1);

         - This sets the default setting of Toggle1 based on the content of the field at OnStart, yes?

     

    Set(defaultLocation, LookUp(ComplianceList, FullName = User().FullName).defaultLocation)

         - What does this do?

     

    Consequently, how should the Patch look, where should I place the Patch command for Toggle1 (I know there is a difference between OnCheck, OnUncheck, OnChange)  go, and where is the Patch sending the information?

     

    I don't have a Patch and I don't have a list or table that is currently collecting the default status of Toggle1.

     

    Patch(...


    I'll describe what Set(varVisible, LookUp(ComplianceList, FullName = User().FullName).varVisible) does to help you understand what's going on here: This lookup searches for the first record in ComplianceList that the current user's name matches a value in the FullName column. When this lookup finds that first match, it will return the value stored in the varVisible field of that same record. Set() will point the global variable varVisible to this return value from the lookup.

    Your app may not need all of these lookups - they are simply ones I used in one of my apps. dispToggle and defaultLocation are additional columns & variables I used in my app and your app may not require these.

    To Patch() a value back to the list (in a behavior formula, usually right after the variable was changed by Set), use code like this:

    Patch(ComplianceList,
     LookUp(ComplianceList, FullName = User().FullName),
     {
     varVisible: varVisible
     }
    )

     

  • Phineas Profile Picture
    5,071 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    Ok, I've changed the condition to include only fields/columns in my lists.

     

    Set(varVisible, LookUp(ComplianceList, FullName = User().FullName).varVisible); 

         - This looks for the default setting on the list, yes?

     

    Set(Toggle1, LookUp(ComplianceList, FullName = User().FullName).Toggle1);

         - This sets the default setting of Toggle1 based on the content of the field at OnStart, yes?

     

    Set(defaultLocation, LookUp(ComplianceList, FullName = User().FullName).defaultLocation)

         - What does this do?

     

    Consequently, how should the Patch look, where should I place the Patch command for Toggle1 (I know there is a difference between OnCheck, OnUncheck, OnChange)  go, and where is the Patch sending the information?

     

    I don't have a Patch and I don't have a list or table that is currently collecting the default status of Toggle1.

     

    Patch(...

  • BCLS776 Profile Picture
    8,988 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    @Phineas wrote:

         

    Set(varVisible, LookUp(UserSettings, AppUserName = User().Email).varVisible);
    Set(dispToggle, LookUp(UserSettings, AppUserName = User().Email).dispToggle);
    Set(defaultLocation, LookUp(UserSettings, AppUserName = User().Email).defaultLocation);

     

    Merely placing the above n the OnStart is going to force Toggle1 to default to the closed position when the app was last saved, yes? There is nothing else I need to do?

     

    I've made a few edits to match my fields. Should the below deliver the outcome I desire?

    Set(varVisible, LookUp(UserSettings, AppUserName = User().FullName).varVisible);

    Set(Toggle1, LookUp(UserSettings, AppUserName = User().FullName).Toggle1);

    Set(defaultLocation, LookUp(UserSettings, AppUserName = User().FullName).defaultLocation)


    The code I posted above will read three values from a list called UserSettings (that already exists and has data in it) and put those into three variables I use in that particular app. Copying the code and changing the names to match some of your control names is only part of making it work. Do you also have a list called UserSettings connected to your app and does it have the exact same columns as my list? If not, you'll need to adjust this code further.

     

    The other part is, and you recognized this in an earlier post, any changed variable data needs to get saved back to the list if you want to use it in the future. You correctly recognized that the Patch() function works for this. If there is no data for the LookUp() function to read in the first place, the app won't set proper values to the variables.

  • Phineas Profile Picture
    5,071 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    I didn't mean to confuse things.

     

    I have visual concept clarity issues.

     

    It takes my time to see some things.

     

    The table I referenced was created in a flow, for another pupose - you are correct I apologize.

         

    Set(varVisible, LookUp(UserSettings, AppUserName = User().Email).varVisible);
    Set(dispToggle, LookUp(UserSettings, AppUserName = User().Email).dispToggle);
    Set(defaultLocation, LookUp(UserSettings, AppUserName = User().Email).defaultLocation);

     

    Merely placing the above n the OnStart is going to force Toggle1 to default to the closed position when the app was last saved, yes? There is nothing else I need to do?

     

    I've made a few edits to match my fields. Should the below deliver the outcome I desire?

    Set(varVisible, LookUp(UserSettings, AppUserName = User().FullName).varVisible);

    Set(Toggle1, LookUp(UserSettings, AppUserName = User().FullName).Toggle1);

    Set(defaultLocation, LookUp(UserSettings, AppUserName = User().FullName).defaultLocation)

  • BCLS776 Profile Picture
    8,988 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    You started this thread asking about doing this with an app, but now you want to use a flow? That's puzzling - are you confusing this with another thread?

     

    I wouldn't use a flow to accomplish the task you originally described.

  • Phineas Profile Picture
    5,071 Super User 2025 Season 1 on at
    Re: Retain Exit Settings for Next OnStart

    I'm using a flow.

     

    This looks like you are doing everything in Power Apps, is that correct?

     

    If you are using a flow how would I make this happen in a flow?

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1