cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Updating the gallery on Approval status

 

I have three buttons in the powerapps(named Approved Rejected pending)

I have to update the gallery based on the approval status

I have two levels of approvals

 

I have given the onselect propery for pending button as

UpdateContext({StatusValue1:"Rejected",StatusValue2:"Pending"}) 

but there can be probability of getting the below conditions to the value when approval status was pending 

I have set the on select property of the button to

PendingButton.OnSelect   but it didn't work..is anyother way ican achieve this ?

UpdateContext({StatusValue1:"Rejected",StatusValue2:"Pending"}) ||
UpdateContext({StatusValue1:"Approved",StatusValue2:"pending"}) || UpdateContext({StatusValue1:"Approved",StatusValue2:"Rejected"})

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @Naresh,

 

You can conditionnaly filter your gallery :

 

OnScreen.Onvisible : Set(GalleryFilter,"") --Default behavior : All records

 

AllButton.OnSelect: Set(GalleryFilter,"")

OpenButton.OnSelect: Set(GalleryFilter,"Pending")

ApprovedButton.OnSelect: Set(GalleryFilter,"Approved")

PendingButton.OnSelect: Set(GalleryFilter,"Complex")

 

Gallery.Items :

Filter(
    DataSource,
    If(
        GalleryFilter = "Complex",
        (StatusValue1 = "Approved" && StatusValue2 = "Pending") || (StatusValue1 = "Rejected" && StatusValue2 = "Pending") || (StatusValue1 = "Approved" && StatusValue2 = "Rejected"),
        GalleryFilter in StatusValue1 && GalleryFilter in StatusValue2
    )
)

Is this the behavior you are looking for ?

 

Théo

View solution in original post

11 REPLIES 11
Highlighted
Memorable Member
Memorable Member

Hey @Naresh

Can you be more specific about what you are trying to do ?

Do you want to filter the gallery according to which button is clicked ?

Like if Pending button is clicked, filter the gallery so it shoes only items that have Pending as either 1st or 2nd approval status ?

 

Théo

Highlighted

yes on tthe pending button click it should show up the result.

 

It should consider both the status values of the appproval one(statusvalue1) and the approval two(statusvalue2)

Highlighted
Memorable Member
Memorable Member

I identify 4 behavior that can be implemented that way :

Screen.OnVisible : Set(GalleryFilter,"")
RejectedButton.OnSelect : Set(GalleryFilter,"Rejected")
PendingButton.OnSelect : Set(GalleryFilter,"Pending")
ApprovedButton.OnSelect : Set(GalleryFilter,"Approved")

Gallery.Items: Filter('Data Source', GalleryFilter in StatusValue1 || GalleryFilter in StatusValue2)

I haven't tried, just tell me how it goes.

Théo
Highlighted

I have only four buttons

 

openbutton -- (pending, pending )

approvedbutton --( approved, approved)

Pendingbutton -- (approved,pending)(rejected,pending)(approved,rejected )

allbutton -- (" "," ")

 

above formula doesn't meet this requiement

please helpme out 

 

Highlighted

Hi @Naresh,

 

You can conditionnaly filter your gallery :

 

OnScreen.Onvisible : Set(GalleryFilter,"") --Default behavior : All records

 

AllButton.OnSelect: Set(GalleryFilter,"")

OpenButton.OnSelect: Set(GalleryFilter,"Pending")

ApprovedButton.OnSelect: Set(GalleryFilter,"Approved")

PendingButton.OnSelect: Set(GalleryFilter,"Complex")

 

Gallery.Items :

Filter(
    DataSource,
    If(
        GalleryFilter = "Complex",
        (StatusValue1 = "Approved" && StatusValue2 = "Pending") || (StatusValue1 = "Rejected" && StatusValue2 = "Pending") || (StatusValue1 = "Approved" && StatusValue2 = "Rejected"),
        GalleryFilter in StatusValue1 && GalleryFilter in StatusValue2
    )
)

Is this the behavior you are looking for ?

 

Théo

View solution in original post

Highlighted

Hi @tchin-nin

 

Exactly this is what I am looking for.

 

But this works only on the same screen.

I have the buttons in one screen and gallery in another screen.

How can I navigate the screen and load the values based on a button click?

Highlighted

Hi @Naresh,

 

The variables created by the Set() function are set at the App level, so they can be used on every screens.

As opposite, the UpdateContext() function allows to create "variables" part of the context of the screen only. Then you can specified a context while navigating to a screen.

 

So you have to choices :

1- Navigate to your gallery screen and specified a context for that screen (the context will be the filter to operate, like my GalleryFilter variable in the previous example)

2- Set Apps variable on the button screen, and use these variable to filter the gallery, like I did by using the Set() function.

The only thing you have to change is on your GalleryScreen.OnVisible property, don't empty the GalleryFilter variable (otherwise you loose your user's choice made on the previous screen)

 

I suggest you to use 2- Apps variables. Because using them across the screens is what they are made for, it is better not to give a Context while navigating to a screen and theses variables can be easily troubleshot (you can see their values in your apps menu)

 

So on each button.OnSelect property should look like:

Set(GalleryFilter,"xxx");

Navigate(GalleryScreen,ScreenTransition.None)

 

Théo

Highlighted

I used the below formula it worked. Is this is the right way?

If(Navigate(M_BrowseScreen,ScreenTransition.None),Set(Filter,"Approved"),false)
(or)
Navigate(M_BrowseScreen,ScreenTransition.None);Set(Filter,"Approved")
Highlighted

Well I dont really understand the first one because can't see any logical test on If first parameter. The navigate function doesn't return True or False.

The second one seems correct to me (It is what I suggest you to do on my previous answer). I would still Set the variable first, before navigating.

I suppose the Set function is well executed even if done after the Navigate but for User Experience I would set the variable first so he doesn't see the filter operate on the gallery (the gallery is already well filetered when arriving on the screen).

 

Théo

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,374)