cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

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
Resolver III
Resolver III

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

9 REPLIES 9
Resolver III
Resolver III

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

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.

 

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!





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

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?

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!





Frequent Visitor

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

I need to add this if condition to "start and wait for an approval" - assigned to field.I have tried,but i an getting error .

 

I need to add if condition to assigned to field on start and wait an approval.Please help me

Helper IV
Helper IV

I need to put below condition to start and wait for an approval - assigned to field.
if(equals(variables('Region'),'APAC'),'mail1',if(equals(variables('Region'),'mail2'),'EMEA','elancheran_e@vfc.com'))

 

Here mail1,mail2 is string variable and it contains multiple approvers mail ID.

 

I have tried this condition and its failed

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (9,424)