cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Roberto_el_Hajj
Advocate III
Advocate III

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
Advocate III
Advocate III

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

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,171)