cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tommyprisco2016
Level: Power Up

How to include a condition to check multiple values in a column

I have a Document Library flow that needs to email a specific person depending on the Country that is selected from a choice list called 'Country'.

 

If United Kingdom, Denmark, Sweden, Finland or Germany are selected then I need Person A to be emailed, for any other country Person B. I thought the below condition would work:

 

@contains(triggerBody()?['Country'], 'United Kingdom', or(contains(triggerBody()?['Country'], 'Denmark', or(contains(triggerBody()?['Country'], 'Sweden', or(contains(triggerBody()?['Country'], 'Finland', or(contains(triggerBody()?['Country'], 'Germany')))))))))

 

But it keeps throwing up the following error:

 

Unable to process template language expressions for action 'Condition_4' at line '1' and column '2485': '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 'Null'.'.

 

Any idea where i am going wrong? Should it be Country Value instead of Country in the condition string?

1 ACCEPTED SOLUTION

Accepted Solutions
Dorul
Level 8

Re: How to include a condition to check multiple values in a column

Hi @tommyprisco2016

You can try a different approach, without the condition.

I have a flow with different departments, but it should be the same - can choose the depart from a list, in sharepoint.

Capture.JPG

 

 

 

 

 

Instead of DEPART, you`ll have Country, of course 🙂 and at Assign to, use this expression: if(equals(variables('Country'),'United Kingdom''),'test1@yyy.com',if(equals(variables('Country'),'Denmark'),'test2@yyy.com','test3@yyy.com'))

 

So, if UK is selected, will send the mail to test1@yyy.com

If Denmark is selected, will send the mail to test2@yyy.com

If anything else is selected, will send the mail to test3@yyy.com

Adapt it to your needs, it should work





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





View solution in original post

7 REPLIES 7
Dorul
Level 8

Re: How to include a condition to check multiple values in a column

Hi @tommyprisco2016

You can try a different approach, without the condition.

I have a flow with different departments, but it should be the same - can choose the depart from a list, in sharepoint.

Capture.JPG

 

 

 

 

 

Instead of DEPART, you`ll have Country, of course 🙂 and at Assign to, use this expression: if(equals(variables('Country'),'United Kingdom''),'test1@yyy.com',if(equals(variables('Country'),'Denmark'),'test2@yyy.com','test3@yyy.com'))

 

So, if UK is selected, will send the mail to test1@yyy.com

If Denmark is selected, will send the mail to test2@yyy.com

If anything else is selected, will send the mail to test3@yyy.com

Adapt it to your needs, it should work





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





View solution in original post

tommyprisco2016
Level: Power Up

Re: How to include a condition to check multiple values in a column

Thanks for the suggestion. I tried it and it worked like a charm. Only thing is having to manage multiple email messages for the same person but it's a small price to pay to get this to work.

 

Dorul
Level 8

Re: How to include a condition to check multiple values in a column

I`m glad it worked!

What do you mean by having to manage multiple email messages for the same person? I thought that was your goal 🙂  to send emails automatically





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





tommyprisco2016
Level: Power Up

Re: How to include a condition to check multiple values in a column

We have 30 Countries and only 1 is managed by 1 person, 6 by another and the rest by a final person. 

 

So for the 1 Country it's 1 case on the switch, the 6 countries managed by the other person needs 6 seperate cases on that switch and then I set all the rest of the countries to the default switch. 

 

The 6 countries will all result in the same email to the same person but I have to set up 6 of these emails..... unless i'm missing something

tommyprisco2016
Level: Power Up

Re: How to include a condition to check multiple values in a column

Ah unless you are saying instead of adding emails under each case to add a new condition under the switch and cases with the variables condition mentioned?

Dorul
Level 8

Re: How to include a condition to check multiple values in a column

Hi @tommyprisco2016

Just build 7 cases, with the 7 countries you need for the 2 people (thats 2 minutes work 🙂 ) And the rest of the countries will go to "Default - if no case contains a matching value".

At TO, use that expression:

if(equals(variables('Country'),'United Kingdom''),'test1@yyy.com',if(equals(variables('Country'),'Denmark'),'test2@yyy.com',if(equals(variables('Country'),'Finland'),'test2@yyy.com'),if(equals(variables('Country'),'Sweden'),'test2@yyy.com'),'test3@yyy.com'))

 

So in my example, UK will be sent to test1@yyy.com and countries selected Denmark, Finland or Sweden will be sent to test2@yyy.com

Any other country selected will be sent to test3@yyy.com

I just tested with a new NORTH department, flow went to "Default - no case" and sent the mail to one of my colleagues set in that expression as last mail (coresponding with test3@yyy.com in my example), so it works for sure 🙂

 

Capture.JPG

 

I presonally prefer it this way, but if you really want conditions, I guess it could work with  2 conditions, using @or, in advanced mode.

 

EDIT: had a few minutes free and i was able to test some things. My surprise is was that we dont really need the cases anyway, at least for me it works just with the 3 steps below, using that "if" expression:

Capture6.JPG

 

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





kchinds
Level: Powered On

Re: How to include a condition to check multiple values in a column

Copying your formatting helped me finish my flow. I was stuck. Thank you!

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,016)