cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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?

 

35 REPLIES 35
Pstork1
Most Valuable Professional
Most Valuable Professional

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
Community Champion
Community Champion

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
Anonymous
Not applicable

@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
Anonymous
Not applicable

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?

Anonymous
Not applicable

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
Most Valuable Professional
Most Valuable Professional

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

ChrisStahl
Frequent Visitor

For those that might struggle with this as I did, I found an answer: coalesce.

In my case, I had added a non-mandatory Yes/No column to a SharePoint list. Those columns populate as empty/null which is NOT the same as false in Power Automate, for those developers who (as I did) wrongly assumed it would.

I wanted to set a Boolean variable using the value stored in this Yes/No field (in this case, whether to send an email or not). So, first I tried:

ChrisStahl_3-1663086620976.png

which, of course, errored out when trying to set a null value to a Boolean.

One option was to set and then reset the values for all of the items in the list so that I knew everything was either true or false with no null values. However, this would not prevent the re-occurrence of this issue in the event another individual was added to the list.

Enter the coalesce function. This will return the first value in its set that is not blank

ChrisStahl_4-1663086664970.png

 


To use in my Set Variable step I wrote:

coalesce(outputs('Get_next_Teammember_by_ID')?['body/SendEmail'], false)


where ('Get_next_Teammember_by_ID') is a previous SharePoint 'Get item by ID' step.

So the step now looks like:

ChrisStahl_2-1663085931865.png

 

 

This prevented me from having to write several conditional checks that I found unnecessary.

I hope this helps someone else out!

Anonymous
Not applicable

In SP lists, Yes/No columns use a small tick to check when Yes. You can make this a bool by using true(checked/yes) or false(unchecked/no) from the dynamic Expressions fx, as in screenshot below.PFX solutions.png

Hi!

 

I'm struggling with Yes/No field too.

1) As @engons said, it doesn't equal to anything meaningful. I tried true, 'TRUE', 'True', 'true', 0, 1

2) In the same time, it is always equal to null or empty regardless of it's value.

3) I tried coalesce approah suggested by @ChrisStahl without any luck.

4) It is always empty if I convert it to string using string() function. Wrong! You can use string() function to convert value to a string: either 'TRUE', or 'FALSE', or blank value.

5) It is possible to convert it to boolean using bool() function but only if there no Blank values in SharePoint. If I add null-check prior to conversion, then it won't work because it is always empty or equals to null (see p. 2).

 

Here are my tests:

IuriiPalchuk_0-1687777173318.png

 

Anonymous
Not applicable

if(equals(string(dynamically select Value of ur True/False column), 'True'), 'Action if true','Action if false')

Hi @Anonymous !

 

As I did mention, string convertion always results in blank value. It is never equal to 'True' or anything else.

Oh gosh, looks like you're right! I just have re-run my test scenario and it definitely works.

I find it amusing and infuriating that after 2 years of this post being out there, there still isn't an answer to what should be the most basic of basic things. SharePoint has a yes/no field. In PowerAutomate you want to make a condition of Yes/No. As the people before have posted, the is literally nothing you can put in for the condition to meet yes

If you look at the reply immediately above yours you will find the answer. A Yes/No column in SharePoint is treated as a Boolean data type. So you need to test for true (yes) and false (no).  Where a lot of people have trouble is that instead of using the Expressions tab to enter the actual Boolean value they enter "True" or "False". Those sometimes work depending on the case you enter them as. But the Boolean value as an expression always works.  But no you can't test for Yes or No. If that's what you want then use a Choice column with those values.

 

Also, the original question here was about testing a Yes/no field using a Switch not a Condition. Switches require a string value so they won't work with Yes/No Boolean fields. Conditions will work if used correctly.



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

of course conditions work. this is so simple its beyond simple, but nobody can tell me, or in this entire string of comments, what SharePoint stores the Yes/No column as.

 

In a SharePoint form, it wouldn't be out of the question to have the slider for "i want something to happen" or "i don't want something to happen".  Like someone already stated, "i want a copy of the emai". If you do the slider in PowerApps, it looks nice, it changes color, you flip the switch from grey to green saying "i want this email".

SharePoint clearly stores something in that column, it displays as a check box in the column. But what does it store in the column that PowerAutomate can read?

In SharePoint Designer, this worked no problem with 1/0. That does not work here.

It is not a 1, yes, YES, true, TRUE, or True. I've tried them all.

Anonymous
Not applicable

Power Automate will always retrieve Yes/No columns as 'True' or 'False'. You can type is as String in your comparison expression. NB: Its case sensitive, just as I have typed above. 

that is what it says on paper, that it was Copilot said to do, that is what lots of people say on the internet, but I'm looking for someone who has actually made a SharePoint list, stored the Yes/No column, put in a condition that if True, moves forward, and didn't get an error.

 

This is the error when putting it True (case sensitive) Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Boolean'.'.

As I said, SharePoint stores it as a Boolean. Its SharePoint that converts it to a Yes/No slider for the convenience of the user, but its stored as a True/False Boolean data type.



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

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (867)