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

How to check the value of a Sharepoint Yes/No field in a switch condition?

I swear Microsoft is making things super difficult for super basic things.

 

Why is it so hard to check the value of a sharepoint Yes/No column in a flow? I checked 10 responses in this forum and they are all different.

 

Why do I need to:

- initialize a special variable;

- deal with triggervalues and stuff;

- deal with "null" values because apparently "unchecked" means "null"???

 

To simply check a Yes/No field. Why do I need to reinvent the wheel for this?

 

8 REPLIES 8
Pstork1
Dual Super User III
Dual Super User III

Switches are used for checking the value of a text string.  If you just want to do something different based on whether a yes/no field is yes or no then just use a condition, not a switch.  The following checks a SharePoint field to see if its Yes.  Nothing else is required.

image.png

  • Trigger conditions are used if you want to keep the flow from running based on a Yes/No field. 
  • I'm not sure where you saw something about a variable.  you will notice I used the True enumeration instead of yes, no, true, or false because there is a case sensitivity issue.
  • Not sure what you mean about No meaning null.  If a yes/no field is set to no then its not null.  If a default is not applied in SharePoint then it might be null.  But that's SharePoint not Power Automate.


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
PrasadAthalye
Super User
Super User

In the condition, convert Yes no column to boolean and compare it with true... I believe this is simple way.

 

PrasadAthalye_0-1626722512890.png

 

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community
WorkHard
Advocate II
Advocate II

@Pstork1 @PrasadAthalye ,

I tried with a simple condition instead of a switch like you both mentioned. The result is the same.

WorkHard_0-1626724200925.png

 or

WorkHard_1-1626724261028.png

or

WorkHard_2-1626724293301.png

 

All 3 methods evaluate to false in any scenario. Regardless if the sharepoint list is checked/Yes.

Can you convert left expression to bool as I requested and then test?

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

I can't see either function you applied in your screenshot.
1. What's the function on the left side of the condition?
2. What's the function in the "Set variable"? 

3. How do I deal with "null" since an unchecked value in sharepoint is considered null?

WorkHard
Advocate II
Advocate II

Update. Here's what I put in the left side of the condition.

Still, no matter what I do, the result is always false.

WorkHard_0-1626729930780.png

 

 

 

if(equals(triggerbody()?['Backup'],'Yes'),true,false)

 

or

if(equals(triggerbody()?['Backup'],true),'true','false')

 

Output:

WorkHard_1-1626730949733.png

 

Pstork1
Dual Super User III
Dual Super User III

Did you set a default on the column?  Is it a standard Yes/No column in SharePoint or is it a Choice column with Yes/No as the Choices?  What trigger are you using and how are you retrieving the Yes/No field?

 

As long as you set a default it should not be null whether its set to either yes or no.  As you can see from the following screenshots it works as I described.  

Flow definition

image.png

When field is set to Yes

image.png

When field is set to No

image.png

Could you provide some screenshots of your SharePoint list definition and the flow.  I'll try to suggest why its not working for you.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
engons
Regular Visitor

I have spent two hours today dealing with the same issue with no result. The Yes/No field does not equals to null, false, true, False, True, (the same values into the expressions dialog), or any other idea I could have. Also, when the inputs of the condition are supposed to be null (empty), the condition receives no input and it is set to true! (Condition was that Yes/No fields are true).

 

I would never have imagined that evaluating a bool variable could be more difficult than programming in brain**bleep** language.

 

Can someone explain how does boolean variables are managed in power automate?

 

Thanks

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,518)