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
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 (1,691)