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

Notifications

Announcements

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

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)
  • Verified answer
    nickduxfield Profile Picture
    497 on at

    If you have a dropdown

    Switch(Status.Selected.Value,

    "Approved", Colour,

    "Rejected", Colour,

    "Option3",Colour,

    DefaultColour)

    If you have a Text Column as source

    Switch(Status,

    "Approved", Colour,

    "Rejected", Colour,

    "Option3",Colour,

    DefaultColour)

     

    Regards

  • Community Power Platform Member Profile Picture
    on at

    Here is what I tried to change color of Label text:

  • Community Power Platform Member Profile Picture
    on at

    So on this same screen I just have a Label that will show ThisItem.Status. Is there a way to set the color depending on if it is Approved, Pending or Denied?

  • nickduxfield Profile Picture
    497 on at

    If using a contextvariable "StateVariable"

    Button.OnSelect

    Switch(StateVariable,

    1,UpdateContext({StateVariable:2}),

    2,1,UpdateContext({StateVariable:2})

    )

     

    Gallery Items

    Switch(StateVariable,

    1,

    SortByColumns(Filter(PendingRequest_Table, Status="Approved"),"DateSubmitted",Descending),

    2,

    SortByColumns(Filter(PendingRequest_Table, Status="Rejected"),"DateSubmitted",Descending)

    )

     

    Please enure you understand the field types

  • nickduxfield Profile Picture
    497 on at
    You should not need 2 screens for this unless formatting is too dissimilar.
    Pass a context variable on navigate(screen2, transition, {statevariable:2})
    Or write to a column in a temp collection that can control States of all screens. Like approved =1, denied =2.
    Use a switch case on a gallery to setup filters for each mode.
  • Community Power Platform Member Profile Picture
    on at

  • Community Power Platform Member Profile Picture
    on at

    So the Status column must have been formated wrong. I changed it to Text and now it is working. Now my next goal is to show only the Approved requests on the ApprovedRequest Screen and the Denied requests on the DeniedRequest Screen. I am thinking I an do this with Filter or is there an easier or better way?

  • nickduxfield Profile Picture
    497 on at

    Investigate the Status field.

    What type of field is it?

    If it is a complex type, meaning, Status is found in a complextype field that has dependencies.

    The error suggests that the Status filed is not what you were expecting, either you changed it to Date and Time by accident, or it is a complect type filed titled status, containing sub fields, or something else.

     

    I.e. 

    PendingRequest_Table( {Title:"",Status: { StartDate:000000,EndDate:00000 } } )

    In this case above you might have to patch the whole thing:

    Patch( PendingRequest_Table, Thisitem, {Status: { StartDate:MyDate,EndDate:MyDate}}) 

     

    If you are able Im happy to sharescreen with you to find out further.

     

  • Community Power Platform Member Profile Picture
    on at

    Okay, the Approve and Deny buttons are in the Gallery. But still getting an error:

  • nickduxfield Profile Picture
    497 on at

    If the Approve Requests button is not placed in the Gallery, the formula Patch(Table, thisItem, {}) wont work.

    Here are your options.

    • Put Approve an Reject Buttons directly in the gallery then Patch(PendingRequests_Table, thisItem, {Status:"Approved"})
    • Change the code to: Patch(PendingRequests_Table,NameofYourGallery.Selected, {Status:"Approved"})

    NameofYourGallery.Selected could be the entry PendingRequests, if not, try name all your galleries to Gallery_SomeName so you can bring them up in your code quickly with no confusion.

     

    More info: If you want to do conditional patches that evaluate everyline, try UpdateIf(source, condition, {})

     

    Ps sorry for jumping in there, I havent answered questions for sometime and Im starting to enjoy it again.

    Regards

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 428

#2
WarrenBelz Profile Picture

WarrenBelz 374 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 333 Super User 2025 Season 2

Last 30 days Overall leaderboard