cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

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
Highlighted
Super User III
Super User III

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
Highlighted
Helper I
Helper I

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

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

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
Highlighted
Helper I
Helper I

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.

Highlighted
Super User III
Super User III

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
Highlighted
Community Support
Community Support

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

Highlighted
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.

Highlighted
Helper I
Helper I

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'])

 

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

Highlighted
Helper I
Helper I

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.

Highlighted
New Member

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (7,135)