cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fernanda
Helper III
Helper III

AND/OR condition not working properly

Hello!

I am working on a flow that after receiving an email, it checks out for 2 different conditions, and if either is met, it creates an item in SP and also triggers an adaptive card to select a user and assign the task. It ends updating the SP item with the name assigned.

My conditions are:

First one: body of the email "Contains the word 'Abast" AND doesnt contain 'Bid'"

OR

Second one: body of the email "Contains the word 'AMA" AND contains the word "Infra'"

It should trigger when either of those groups of conditions are met.

I have tested them both separately, and they work perfectly, but when I put them together, it fails

What am i doing wrong here???

Fernanda_1-1620663316620.png

Thanks in advance for your help!!

1 ACCEPTED SOLUTION

Accepted Solutions
eliotcole
Continued Contributor
Continued Contributor

Ah, sorry, @Fernanda , that was my mistake, but also, you are still searching for upper case letters ;-).

 

I wrote out the expression that way to show the logic, but somehow it put spaces around the question marks, remove those spaces and it will work. So this is for my flow:

or(and(contains(toLower(outputs('Html_to_text')?['body']), 'abast'), not(contains(toLower(outputs('Html_to_text')?['body']), 'bid'))), and(contains(toLower(outputs('Html_to_text')?['body']), 'ama'), contains(toLower(outputs('Html_to_text')?['body']), 'infra')))

 

I have edited the original reply, if that helps, and this is what yours should look like ... this will work:

or(and(contains(toLower(outputs('Html_to_text')?['body']), 'abastecimiento'),not(contains(toLower(outputs('Html_to_text')?['body']), 'licitación'))),and(contains(toLower(outputs('Html_to_text')?['body']), 'aguasmagallanes.cl'),contains(toLower(outputs('Html_to_text')?['body']), 'infraestructura')))

 

If you can see, the other reason that yours is showing the wrong results is because you are searching for:

Licitación

You should be searching for:

licitación

 

---

 

How this works is that the toLower() function takes all of the text and makes every letter lower case.

A --> a, B --> b, C --> c, etc

So, when you search for a word in there with contains() you must make sure that you search for the lower case version of the word, in the above example that is "licitación" 😀.

View solution in original post

5 REPLIES 5
eliotcole
Continued Contributor
Continued Contributor

Hi, @Fernanda , it looks good, I think that the only thing that might be an issue is that a condition will only fire on the exact text, which is case sensitive.

 

So it will fire on "Abast" but it will not fire on "abast".

 

I just tried it with the following (I placed spaces in my condition, I don't know why 😅), and it worked:

working on specific text case sensitiveworking on specific text case sensitive

 

 

What you can do is use the toLower() function in an expression and just search all the words on their lower case values:

toLower() - EDITED WITH LOWER CASE CONDITIONtoLower() - EDITED WITH LOWER CASE CONDITION

 

I've just tested this against a previous test that had the capitalised AMA and Infra in them and it works.

 

----

 

If you're wondering why the extra steps, I have accounted for whether or not the email is an HTML encoded email, in which case I take only the words using the HTML to text connector, and use a toLower() on that to get the text needed to parse / search.

 

----

 

EDIT 2

 

I have made a 'slim' version of this:

  1. The first action is the Html to text action, on all emails. (because if it is just plain text, then it will stay as text)
  2. Then it initialises a boolean variable with the following code:

 

 

or(
    and(
        contains(toLower(outputs('Html_to_text')?['body']), 'abast'),
        not(contains(toLower(outputs('Html_to_text')?['body']), 'bid'))
		),
    and(
        contains(toLower(outputs('Html_to_text')?['body']), 'ama'),
        contains(toLower(outputs('Html_to_text')?['body']), 'infra')
		)
)

 

 

Here that is in one long string:

or(and(contains(toLower(outputs('Html_to_text')?['body']), 'abast'), not(contains(toLower(outputs('Html_to_text')?['body']), 'bid'))), and(contains(toLower(outputs('Html_to_text')?['body']), 'ama'), contains(toLower(outputs('Html_to_text')?['body']), 'infra')))

That is your AND/OR group as an expression, and using the output of the Html to text action.

 

two stepstwo steps

 

Hello @eliotcole !

Thanks for trying to help me!!

The email I am reading is a standard type of email, so I wrote the data exactly as it comes, this is why, separately, works perfectly, but together, it doesnt, emails that shouldn't trigger the flow, are slipping through and activate it.

So, I tried your second approach, but, it keeps giving me a false result, so it doesn't trigger the flow.

This is real data on my variable:

or(and(contains(toLower(outputs('Html_to_text') ? ['body']), 'Abastecimiento'),not(contains(toLower(outputs('Html_to_text') ? ['body']), 'Licitación'))),and(contains(toLower(outputs('Html_to_text') ? ['body']), 'aguasmagallanes.cl'),contains(toLower(outputs('Html_to_text') ? ['body']), 'Infraestructura')))

 

Fernanda_0-1620682355912.png

 

eliotcole
Continued Contributor
Continued Contributor

Ah, sorry, @Fernanda , that was my mistake, but also, you are still searching for upper case letters ;-).

 

I wrote out the expression that way to show the logic, but somehow it put spaces around the question marks, remove those spaces and it will work. So this is for my flow:

or(and(contains(toLower(outputs('Html_to_text')?['body']), 'abast'), not(contains(toLower(outputs('Html_to_text')?['body']), 'bid'))), and(contains(toLower(outputs('Html_to_text')?['body']), 'ama'), contains(toLower(outputs('Html_to_text')?['body']), 'infra')))

 

I have edited the original reply, if that helps, and this is what yours should look like ... this will work:

or(and(contains(toLower(outputs('Html_to_text')?['body']), 'abastecimiento'),not(contains(toLower(outputs('Html_to_text')?['body']), 'licitación'))),and(contains(toLower(outputs('Html_to_text')?['body']), 'aguasmagallanes.cl'),contains(toLower(outputs('Html_to_text')?['body']), 'infraestructura')))

 

If you can see, the other reason that yours is showing the wrong results is because you are searching for:

Licitación

You should be searching for:

licitación

 

---

 

How this works is that the toLower() function takes all of the text and makes every letter lower case.

A --> a, B --> b, C --> c, etc

So, when you search for a word in there with contains() you must make sure that you search for the lower case version of the word, in the above example that is "licitación" 😀.

View solution in original post

Hey @eliotcole 

I made the correction, and it works like a charm!!

thanks so much for your help!!!!

eliotcole
Continued Contributor
Continued Contributor

WHOOP! WHOOP!!

 

🎉

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,225)