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 Platform Community / Forums / Power Apps / UpdateContext and Visi...
Power Apps
Answered

UpdateContext and Visibility

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a couple questions. I have built a Time Off Request app for our employees. I made a PendingRequests Screen where the managers login to approve or deny requests. I used UpdateContext to update the Status column in my Excel depending of if they click Approve or Deny but nothing is populated in my Excel. Here is my OnSelect statement:

 

Office365.SendEmail(Email,"Time Off Request","Your time off request has been approved.");

UpdateContext({Status:"Approved"})

 

Second question is on Visibility, I have 3 screens: PendingRequests, ApprovedRequests, and DeniedRequests. So once a request is Approved or Denied, I want the request to only be visible on the appropriate Screen. So on Visible statement I tried:

 

If (Status = "Approved")

 

but it did not work, any help would be appreciated. Thank you!

Categories:
I have the same question (0)
  • RusselThomas Profile Picture
    4,014 on at

    Hi thunter,

     

    UpdateContext() is used to set a temporary variable on the current screen, that is local to that screen.  It will only update the variable in the PowerApps session, not update the source, (which in this case I'm assuming to be your Excel sheet).

     

    To update the source, you need to either use an Edit form and a Submit() function, or a Patch() function.

     

    If you use an Edit form, you can then also use the OnSuccess: property for the form to send your email, this makes sure it only sends the email if the update succeeds.

     

    Assuming for now you're not using a form, your Patch() statement would look something like this;

    Patch(ExcelSource, RowToUpdate, {Status: "Approved"})

    where RowToUpdate is a function that returns the specific row you want to update - this may be a LookUp(), or, in the context of a Gallery item, assuming the button you're pressing is inside the Gallery item, you can just use ThisItem

     

    As for the screens, you can't control whether a screen is 'visible' or not - only controls and elements on the screen carry this property.  If you're using a Gallery or something similar to display data on the screen, then you would typically just filter the data according to the Status for that Gallery on that screen - so a Gallery displaying data on your PendingRequests screen might have its Items: property set to;

    Filter(ExcelSource, Status="Pending")

    whereas on your ApprovedRequests screen the Gallery showing the data for that screen might have its Items: property set to;

    Filter(ExcelSource, Status="Approved")

     

    Not sure if this helps you, perhaps you can provide some screenshots for additional context to help determine the best solution?

     

    Kind regards,

     

    RT

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for your feedback. Yes, you are correct, I want to make the Gallery visible on the ApprovedRequests screen if the Status is Approved and visible on the DeniedRequests if the Status is Denied. I also tried to use UpdateContext({Status:"Approved"}) but it doesnt work. Is that where I would use the Filter command as you stated?

  • RusselThomas Profile Picture
    4,014 on at

    Hi thunter,

     

    Would it be possible to post some screenshots so I can get a better look at what we're dealing with? 🙂

     

    Kind regards,


    RT

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    You need to Patch the datasouce to actually change it, (Lookup Patch function in PowerApps).  UpdateContext just creates a temporary variable. In your case, you can use UpdateContext() to create a variable and set it to either true or false since the Visible property must equate to either true or false. So in the OnSelect property of the button the UpdateContext({approved:true}), Set the Visible property to "approved" (without the quotes).  If you want the Visible property of a form, control, label, etc. to hide when the screen opens, set the OnVisible property of the screen to UpdateContext({approved:false}).  Hope this helps.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I read the document on the Patch function and here is what I tried:

    Patch(PendingRequest_Table, Status, "Denied")

    PendingRequest_Table is a Sheet in my Excel

    Status is the Column I want updated

    "Denied" is what I want to populate the column with

  • RusselThomas Profile Picture
    4,014 on at

    Hi thunter,

     

    Thanks for the screenshot 🙂

     

    Your formula should work, assuming it's on the OnSelect: property of the Tick icon and the Tick icon is inside a gallery row and not on top of it or elsewhere in the screen hierarchy.  I also assume the data in the Gallery row is from the PendingRequestsTable?

     

    What is the error on the Tick icon?

     

    Kind regards,

     

    RT

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

  • RusselThomas Profile Picture
    4,014 on at

    The format of your Patch() statement seems to have changed from the first pic.....but I see you have the cross selected now instead of the tick.

     

    The correct format is 

    Patch(source, record, {column: "value"})

    can you update your Patch statement to 

    Patch(PendingRequest_Table, ThisItem, {Status: "Denied"})

    for the cross and 

    Patch(PendingRequest_Table, ThisItem, {Status: "Approved"})

    for the tick and then show what the error is?

     

    Thanks 🙂

     

    RT

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    so the sheet is actually titled PendingRequests so not sure if I shoudl use that or PendingRequestsTable, here is my Excel

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard