cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
OC-ITServices
Level: Powered On

How to apply a case insensitive condition to an email based flow?

Hello,

I have a flow that works for the most part, however it seems that the primary condition in my flow (email subject contains) is case sensitive...

I'm trying to write a condition that if the email subject contains the words "new employee" that a flow is triggered. However it seems that the contains option doesn't have as case insensitive option. For example "new employee" or "New Employee" or "NEW EMPLOYEE" should all trigger the same flow. 

 

Is there an option that can be triggered regardless of case ?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to apply a case insensitive condition to an email based flow?

Hi @ OC-ITServices,

 

 

I have try the expression below in the Condition:

@contains(toUpper(triggerBody()?['Subject']), 'NEW EMPLOYEE')

And the flow as below:

Capture.PNG

 

And when I send the email with subject as "new EMPLOYEE", the flow would run successfuly as below:

Capture.PNG

 

I afraid there is something wrong on the expression "contains(triggerBody()?['To'], 'person1@someplace.com;person2@someplace.com')" in your Condition.

 

Do you want to check if the email is sent to "person1@someplace.com" or "person2@someplace.com"?

Or do you want to check if the email is sent to "person1@someplace.com" and "person2@someplace.com"?

 

If you want to check if the email is sent to "person1@someplace.com" or "person2@someplace.com",please enter the expression below in the Condition:

@and(contains(toUpper(triggerBody()?['Subject']), 'NEW EMPLOYEE'),or(contains(toLower(triggerBody()?['To']), 'person1@someplace.com'),contains(toLower(triggerBody()?['To']), 'person2@someplace.com')))

 

If you want to check if the email is sent to "person1@someplace.com" and "person2@someplace.com",please enter the expression below in the Condition:

 

@and(contains(toUpper(triggerBody()?['Subject']), 'NEW EMPLOYEE'),or(contains(toLower(triggerBody()?['To']), 'person1@someplace.com;person2@someplace.com'),contains(toLower(triggerBody()?['To']), 'person2@someplace.com;person1@someplace.com')))

 

Please let me know if your problem could be solved.

 

 

Regards,
Alice Zhang

View solution in original post

11 REPLIES 11
Super User
Super User

Re: How to apply a case insensitive condition to an email based flow?

Have you tried converting the subject line to a single case using either the toUpper() or toLower() expressions and then comparing against a single case string?

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

Scott
OC-ITServices
Level: Powered On

Re: How to apply a case insensitive condition to an email based flow?

I have not, but I will now.
Super User
Super User

Re: How to apply a case insensitive condition to an email based flow?

If you need additional help - please post here.

 

If this solves your issue, please mark your issue as Solved.

 

Good luck!

 

Scott

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

Scott
OC-ITServices
Level: Powered On

Re: How to apply a case insensitive condition to an email based flow?

Would the condition be something like this:

 

 

@and(contains(toUpper(triggerBody()?['Subject']), 'NEW EMPLOYEE'),contains(triggerBody()?['To'], 'person1@someplace.com;person2@someplace.com'))

 

I've tried this, but it seems to fail.

Super User
Super User

Re: How to apply a case insensitive condition to an email based flow?

Please provide the specifics of what you are trying to accomplish and I will try to assist.

 

Scott

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

Scott
Community Support Team
Community Support Team

Re: How to apply a case insensitive condition to an email based flow?

Hi @ OC-ITServices,

 

 

I have try the expression below in the Condition:

@contains(toUpper(triggerBody()?['Subject']), 'NEW EMPLOYEE')

And the flow as below:

Capture.PNG

 

And when I send the email with subject as "new EMPLOYEE", the flow would run successfuly as below:

Capture.PNG

 

I afraid there is something wrong on the expression "contains(triggerBody()?['To'], 'person1@someplace.com;person2@someplace.com')" in your Condition.

 

Do you want to check if the email is sent to "person1@someplace.com" or "person2@someplace.com"?

Or do you want to check if the email is sent to "person1@someplace.com" and "person2@someplace.com"?

 

If you want to check if the email is sent to "person1@someplace.com" or "person2@someplace.com",please enter the expression below in the Condition:

@and(contains(toUpper(triggerBody()?['Subject']), 'NEW EMPLOYEE'),or(contains(toLower(triggerBody()?['To']), 'person1@someplace.com'),contains(toLower(triggerBody()?['To']), 'person2@someplace.com')))

 

If you want to check if the email is sent to "person1@someplace.com" and "person2@someplace.com",please enter the expression below in the Condition:

 

@and(contains(toUpper(triggerBody()?['Subject']), 'NEW EMPLOYEE'),or(contains(toLower(triggerBody()?['To']), 'person1@someplace.com;person2@someplace.com'),contains(toLower(triggerBody()?['To']), 'person2@someplace.com;person1@someplace.com')))

 

Please let me know if your problem could be solved.

 

 

Regards,
Alice Zhang

View solution in original post

Anonymous
Not applicable

Re: How to apply a case insensitive condition to an email based flow?

How could you apply this case insensitive condition to attachment file extensions? I am having a problem where attachments that are ".PDF" as opposed to ".pdf" do not get included in the flow. The flow checks for emails in a specific folder in outlook for pdf attachments and saves them into a SharePoint folder. I just don't know enough about the language to know where to put the toUpper function. Thanks.

OC-ITServices
Level: Powered On

Re: How to apply a case insensitive condition to an email based flow?

Should be something like (I have not tested this yet):

 

@contains(items('Apply_to_each_Attachment_on_the_email')?['NAME'],toLower(triggerBody()?['.pdf'])

 

Anonymous
Not applicable

Re: How to apply a case insensitive condition to an email based flow?

Thanks @OC-ITServices, unfortunately when I tried your suggestion I received the following error when attempting to save the flow:

The template validation failed: 'The template action 'Condition_2' at line '1' and column '2812' is not valid: "Unable to parse template language expression 'contains(items('Apply_to_each_Attachment_on_the_email')?['NAME'],toLower(triggerBody()?['.pdf'])': expected token 'RightParenthesis' and actual 'EndOfData'.".'.

OC-ITServices
Level: Powered On

Re: How to apply a case insensitive condition to an email based flow?

Sorry about that. Unfortunately I don't have time at the moment to test/troubleshoot this. I'd recommend you start a new thread for your issue, and you might get faster answer (since this thread was already marked as solved.

Neha_Lakhesar
Level: Power Up

Re: How to apply a case insensitive condition to an email based flow?

Try using "OR" by using function "Add row" in the Condition as mentioned in below screenshot.

This worked in my case:

 

Capture.PNG

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

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!

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
Users online (5,181)