cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kayleegoose
Level: Powered On

Workaround for not being able to use 'contains' in switch case instead of 'equals'

I know this has been suggested as an idea, but I don't see a workaround for this. (Which is extra frustrating because I have to do it this way because I'm using a workaround for checking multiple value checkboxes, but here we are) 

 

What I'm doing is working with calendars. Say Calendar 1, A, B, and C. I have a column on Calendar 1 called "Applies To" and the choices are A, B, and C. These are checkboxes. So when the users add something to Calendar 1, and choose A, B, or C, the workflow adds the items to whichever calendars are selected. So if someone adds an item, and chooses B, the workflow needs to add the item to Calendar B as well. 

 

Since Flow apparently can't handle looping through checkbox selections and run conditions based on the selections, my workaround is to loop through the selections and add them all to a string variable. Then I check if the variable contains B (for example), and if it does, I create the new item on B. 

 

It would be very nice to not have to do a bunch of regular If statements and could just do a switch case, but it only gives me the option to check 'equals' on the case. I need it to do 'contains'. 

 

I laid out this whole situation in case there's a better way to handle this that I'm missing, because I'm sure that I'm not the first person to try to do something like this. 

 

Thanks! 

4 REPLIES 4
kayleegoose
Level: Powered On

Re: Workaround for not being able to use 'contains' in switch case instead of 'equals'

Want to add that the string comes back like this: 

 

{"Id":0,"Value":"A"}{"Id":1,"Value":"B"}{"Id":2,"Value":"C"}

 

I'm going to try to do some sort of substring method, but I still wish there was a simpler answer to something that really should be very basic, so I'll leave this up for thoughts. 

 

Community Support Team
Community Support Team

Re: Workaround for not being able to use 'contains' in switch case instead of 'equals'

Hi @kayleegoose,

 

Could you please show a bit more about the Calendar 1, A, B and C that you mentioned?

Do you want to use contains operator within Switch case action in Microsoft Flow?

 

I afraid that there is mo way to use contains operator within Switch case action in Microsoft Flow currently, the Switch case action only support equals operator. If you would like this feature to be added in Microsoft Flow, please submit an idea to Flow Ideas Forum:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

 

More details about the usage of Switch case action, please check the following article:

https://flow.microsoft.com/en-us/blog/search-by-service/

 

In addition, you could consider take a try to add nested Conditions within your flow instead of Switch case to achieve your needs. Within Condition box, you could use Contains operator. More details about the usage of nested Conditions, please check the following article:

Nested Conditions

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Lexnnn
Level: Powered On

Re: Workaround for not being able to use 'contains' in switch case instead of 'equals'

I needed to send email to users only once and not repeat their email address.

This is what I have done:

if(empty(item()?['Address']),'blank',item()?['Address'])

flow contains.JPGflow contains 2.JPG

CGallardo1
Level: Powered On

Re: Workaround for not being able to use 'contains' in switch case instead of 'equals'

Hi,

I had a similar probIem and I worked around it by:

Converting the string to an array (use split). In your case I think it would be the string that loops through the selections and adds them all to a string variable.  

You can then Set up an Apply to each and inside it set up your Case switch

 

Helpful resources

Announcements
firstImage

Microsoft Flow Online Conference

Join us for a FULL day of FREE Microsoft Flow Sessions from some of the best minds in the industry!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

thirdImage

New Flow Community Board!

Check out the new Microsoft Flow Community Blog Topic Suggestion board!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 47 members 4,322 guests
Recent signins:
Please welcome our newest community members: