cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

How to use OR in IF condition to verify control values?

Hello,

 

I have three controls as follows:

 

  • Dropdown1
  • Dropdown2
  • Dropdown3

On Submit Button click, I need to verify if any of the value is blank, therefore, I have applied following formula on button click:

 

If(IsBlank(Dropdown1.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

If(IsBlank(Dropdown2.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

If(IsBlank(Dropdown3.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }))

 

Although above is working as expected, I need something as follows:

 

If any of the dropdown values are blank, "Result 1", "Result 2"

 

If and Switch condition did not work for me, Also "Or" or "||" operators were not resulting as expected too. Probably I am doing something wrong, but I gave up!

 

Can you please help me in optimizing this formula further?

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: How to use OR in IF condition to verify control values?

@dave8 
Here you go... I made a small syntax error.  Missing a closing bracket on the last line.

If(
    !IsBlank(Dropdown1.Selected.Value)=true,
    And !IsBlank(Dropdown2.Selected.Value)=true
    And !IsBlank(Dropdown3.Selected.Value)=true,
    UpdateContext({ValidationConfirm: true}),
    UpdateContext({ValidationConfirm: false})
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
Highlighted
Super User III
Super User III

Re: How to use OR in IF condition to verify control values?

@dave8 

I think this is the formula you will need to check if all the dropdown inputs have a value.

 

If(
    !IsBlank(Dropdown1.Selected.Value)=true,
    And !IsBlank(Dropdown2.Selected.Value)=true
    And !IsBlank(Dropdown3.Selected.Value)=true,
    UpdateContext({ValidationConfirm: true}),
    UpdateContext({ValidationConfirm: false}
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

Highlighted
Post Prodigy
Post Prodigy

Re: How to use OR in IF condition to verify control values?

Thank you for your attention, however it still throws an error:

 

Note: I have removed "," after first condition, as it was not needed in formula.

 

valerror.png

What could be wrong? I have faced the same error while trying earlier as well with other alternatives!

 

Thanks!

Highlighted
Super User III
Super User III

Re: How to use OR in IF condition to verify control values?

@dave8 
Here you go... I made a small syntax error.  Missing a closing bracket on the last line.

If(
    !IsBlank(Dropdown1.Selected.Value)=true,
    And !IsBlank(Dropdown2.Selected.Value)=true
    And !IsBlank(Dropdown3.Selected.Value)=true,
    UpdateContext({ValidationConfirm: true}),
    UpdateContext({ValidationConfirm: false})
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Highlighted
Post Prodigy
Post Prodigy

Re: How to use OR in IF condition to verify control values?

Thank you!

 

Below formula has removed syntax error, however it doesn't execute the Result One!

 

If(
    !IsBlank(Dropdown1.Selected.Value)=true
    And !IsBlank(Dropdown2.Selected.Value)=true
    And !IsBlank(Dropdown3.Selected.Value)=true,
    UpdateContext({ValidationConfirm: true}),
    UpdateContext({ValidationConfirm: false})
)

 

While below formulas does:

 

If(IsBlank(Dropdown1.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

If(IsBlank(Dropdown2.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

If(IsBlank(Dropdown3.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

 

I have also faced above behaviour earlier, What could be missing now?

 

Thanks,

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,953)