cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
OC-ITServices
Helper I
Helper I

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

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

12 REPLIES 12
ScottShearer
Super User
Super User

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

I have not, but I will now.

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

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.

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

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

Anonymous
Not applicable

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.

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

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'.".'.

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
New Member

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

This worked in my case:

 

Capture.PNG

EnzoDellAquila
New Member

The straight way to solve this should be set this condition (note: $myField is the variable that contains the string you want to match):

 

toUpper($myField) contains SOMETHING

 

But if I use toUpper() then I can't select $myField, I only can see some variables but not all.

 

This is how I managed it: I created a compose action and I set the input to $myField and then I used the @toUpper(outputs('Compose')) in the contains expression.

 

This worked. Now I can match the object of an email in a case insensitive manner and the condition is true if it contains Ferie, FERiE, ferie or permesso, PERMESSO, pErmEssO.

 

(PowerAutomate in Italian language)(PowerAutomate in Italian language)

 

 

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (2,199)