cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Darren137227
Resolver I
Resolver I

Help with Nestled if Statement to disable, enable button

Hi I have a canvas app and trying to enable disable a button called /Complete' on the button's display mode property with nestled if statement but button stays disabled.

 

So I have a field called CboTaskType. It's tied to an option set field, with values, Declaration, Endorsement and Policy.

I also have field called QCendTime tied to a Date and time Field

I have a gallery with items in them that each have a check box called CheckBox1.

 

What I need is, If the Task type is declaration and all the items in the gallery have their Checkbox1 ticked, then enable the button or disable it. This is the first if. This works if I keep it to this single if statement. However I need a second if statement to check that if the TaskType is either a Endorsement or Policy and the QC End Time isn't blank, then enable the button or else disable it.


My statement is as such
If(cboTaskType.Selected.Value = 'Task Type (Policy_bind_tasks)'.Declaration And
CountIf(Documentgallery.AllItems,Checkbox1.Value=false)>0,DisplayMode.Disabled,
cboTaskType.Selected.Value='Task Type (Policy_bind_tasks)'.Endorsement Or cboTaskType.Selected.Value='Task Type (Policy_bind_tasks)'.Policy And Not(IsBlank(QCendTime)),DisplayMode.Edit,DisplayMode.Disabled)

However the button stays disabled when task type is of Declaration and the gallery has all of its comboBox1 boxes checked.
The Endorsement or Policy statement part works- button is disabled for Policies and Endorsements if QCEnd time is bank, enabled when not.
Can someone help

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Darren137227 ,

A few brackets here on the and/or combinations - you will need to check I have your logic correct.

If(
   (
      cboTaskType.Selected.Value = 'Task Type (Policy_bind_tasks)'.Declaration &&
      CountRows(
         Filter(
            Documentgallery.AllItems,
            !Checkbox1.Value
         )
      ) = 0 
   ) ||
   (
      (
         cboTaskType.Selected.Value='Task Type (Policy_bind_tasks)'.Endorsement ||
         cboTaskType.Selected.Value='Task Type (Policy_bind_tasks)'.Policy
      ) && 
      !IsBlank(QCendTime),
   )
   DisplayMode.Edit,
   DisplayMode.Disabled
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @Darren137227 ,

A few brackets here on the and/or combinations - you will need to check I have your logic correct.

If(
   (
      cboTaskType.Selected.Value = 'Task Type (Policy_bind_tasks)'.Declaration &&
      CountRows(
         Filter(
            Documentgallery.AllItems,
            !Checkbox1.Value
         )
      ) = 0 
   ) ||
   (
      (
         cboTaskType.Selected.Value='Task Type (Policy_bind_tasks)'.Endorsement ||
         cboTaskType.Selected.Value='Task Type (Policy_bind_tasks)'.Policy
      ) && 
      !IsBlank(QCendTime),
   )
   DisplayMode.Edit,
   DisplayMode.Disabled
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

WarrenBelz
Super User
Super User

Hi @Darren137227 ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi Warren,

 

I added your syntax but had some errors, so removed the two opening "( (" after the first || and removed
the ")" after the .Policy and removed the ")" directly after (QCEndTime),

 

So syntax is:
If(
(
cboTaskType.Selected.Value = 'Task Type (Policy_bind_tasks)'.Declaration &&
CountRows(
Filter(
Documentgallery.AllItems,
!Checkbox1.Value
)
) = 0
) ||


cboTaskType.Selected.Value='Task Type (Policy_bind_tasks)'.Endorsement ||
cboTaskType.Selected.Value='Task Type (Policy_bind_tasks)'.Policy
&&
!IsBlank(QCendTime), DisplayMode.Edit, DisplayMode.Disabled
)

Helpful resources

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

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,229)