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

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.
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.
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

Roberto_el_Hajj
Advocate II
Advocate II

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

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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