cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Roberto_el_Hajj
Helper V
Helper V

How to disable Gallery items based on a specific criteria ?

Hello,

 

I have a canvas app that is connected to Dataverse, inside the app I have a gallery that contains multiple projects, in the gallery I have a button that navigates the user to a different screen.

 

The scenario that I want to achieve:

 

I want to disable all the buttons only if the data returned in the gallery has a specific flag column (Yes/No) as Yes.

For example, Let's say I have 5 records and the 4th record has the flag column = yes, then all those 5 records should be disabled and not editable.

 

The formula that I tried:

f(
    varcheckinID = 3,
    DisplayMode.Edit,
    If(
        CountRows(
            Filter(
                'Timesheet Schedules',
                'Sched. ID' = ThisItem.'Sched. ID' && TypeFlag = 'TypeFlag (Timesheet Schedules)'.Yes
            )
        ) >= 1,
        DisplayMode.Disabled,
        DisplayMode.Edit
    )
)

 

Screenshots :

 

When the flag value is NO for all the projects:

Roberto_el_Hajj_1-1642189748592.png

 

When the flag value of one project is YES I want it to disable the displaymode of all the items  :

Roberto_el_Hajj_0-1642189726244.png

 

 

What should be the updated formula to achieve the above scenario?

Please let me know if you need any further information.

 

Any help is highly appreciated.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Roberto_el_Hajj 

This is a scenario where a control outside of the Gallery is a helper.  It does not have to be visible.

But, a label outside of the Gallery (let's call it lblTypeCount) with the following Text property formula:

CountRows(Filter(yourGallery.AllItems, TypeFlag = 'TypeFlag (Timesheet Schedules)'.Yes))

 

Then in your gallery button DisplayMode property formula:

If(IfError(Value(lblTypeCount.Text), 0)>0
    Disabled,
    Edit
)

 

That would provide what you need without the cost of doing data filters on each item in your gallery.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@Roberto_el_Hajj 

This is a scenario where a control outside of the Gallery is a helper.  It does not have to be visible.

But, a label outside of the Gallery (let's call it lblTypeCount) with the following Text property formula:

CountRows(Filter(yourGallery.AllItems, TypeFlag = 'TypeFlag (Timesheet Schedules)'.Yes))

 

Then in your gallery button DisplayMode property formula:

If(IfError(Value(lblTypeCount.Text), 0)>0
    Disabled,
    Edit
)

 

That would provide what you need without the cost of doing data filters on each item in your gallery.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Roberto_el_Hajj
Helper V
Helper V

Hello @RandyHayes , thanks for your help, I really appreciate it.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,471)