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

Using AND/OR in same condition

Question: If we are having a condition like "If status equal approved and (  modifiedby equals 'User1' OR  modifiedby equals 'User2')"  how to implement this condition in flow.

 

I have tried  AND / OR condition like below:

 

@or(
equals(body('Update_item')?['Editor']?['DisplayName'], 'Kumawat, Chandrashekhar'),

equals(body('Update_item')?['Editor']?['DisplayName'], body('Update_item')?['Author']?['DisplayName'])
)

 

@AND(
equals(body('Update_item')?['Editor']?['DisplayName'], 'Kumawat, Chandrashekhar'),

equals(body('Update_item')?['Editor']?['DisplayName'], body('Update_item')?['Author']?['DisplayName'])
)

 

and both this works fine.

 

But i want to use OR condition inside AND like below:

 


@and(
     equals(body('Update_item')?['Editor']?['DisplayName'], 'Kumawat, Chandrashekhar [AUTOSOL/PSS/PUNE]'),

@or(
    equals(body('Update_item')?['Editor']?['DisplayName'], body('Update_item')?['Author']?['DisplayName']),
    equals(body('Update_item')?['Editor']?['DisplayName'], body('Update_item')?['Author']?['DisplayName'])
   )
)     // this does not work. please suggest

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Using AND/OR in same condition

Hi @chandrashekhar,

 

Please modify the formula as below:

@and(
     equals(body('Update_item')?['Editor']?['DisplayName'], 'Kumawat, Chandrashekhar [AUTOSOL/PSS/PUNE]'),

     or(
    equals(body('Update_item')?['Editor']?['DisplayName'], body('Update_item')?['Author']?['DisplayName']),
    equals(body('Update_item')?['Editor']?['DisplayName'], body('Update_item')?['Author']?['DisplayName'])
         )
)   

 

There is no need to add another "@" ahead of the or function.

Removing it should make the formula work.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

16 REPLIES 16
Community Support Team
Community Support Team

Re: Using AND/OR in same condition

Hi @chandrashekhar,

 

Please modify the formula as below:

@and(
     equals(body('Update_item')?['Editor']?['DisplayName'], 'Kumawat, Chandrashekhar [AUTOSOL/PSS/PUNE]'),

     or(
    equals(body('Update_item')?['Editor']?['DisplayName'], body('Update_item')?['Author']?['DisplayName']),
    equals(body('Update_item')?['Editor']?['DisplayName'], body('Update_item')?['Author']?['DisplayName'])
         )
)   

 

There is no need to add another "@" ahead of the or function.

Removing it should make the formula work.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Re: Using AND/OR in same condition

Than you Michael . That worked great!! Thanks a lot!!

satya
Level: Powered On

Re: Using AND/OR in same condition

Hi,

 

i have a date column in sharepoint list i need to send a mail before 7 days, i am using below formula it is giving error. could you please help me.

 

@and(less(items('Apply_to_each')?['Sp_x00e4_testens_x0020_zu_x0020_'], addDays(utcNow(), 8)),
(greater(items('Apply_to_each')?['Sp_x00e4_testens_x0020_zu_x0020_'], addDays(utcNow(), 6))
)

 

i have tried with equal also, it is not comparing.

@equals(items('Apply_to_each')?['Sp_x00e4_testens_x0020_zu_x0020_'], addDays(utcNow(), 3))

Re: Using AND/OR in same condition

Hi Satya,

 

You can use something like this:

 

use this:

@equals(formatDateTime(item()?['Sp_x00e4_testens_x0020_zu_x0020_'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 7), 'MM/dd/yyyy'))

 

instead of :

@equals(items('Apply_to_each')?['Sp_x00e4_testens_x0020_zu_x0020_'], addDays(utcNow(), 3))

 

Please refer below link for more detailed approach:

FLOW TO SEND EMAIL WHEN DATE APPROACHES

 

H-F
Level: Powered On

Re: Using AND/OR in same condition

I tried to constuct my formula the same as seen here but it does not work for me.

My flow has the following 2 parallel branches to send an email.  Both have the same AND portion of Status='Pending HR Approval'.

#1 should send email 1 only when the location is Perrysburg or Bridgewater.

#2 should send email 2 if the location is anything other than Perrysburg or Bridgwater (thus NOT Perrysburg or Bridgwater).

 

How it currently works with the formulas below:

1-The problem is that if the location is either Perrysburg or Bridgwater, both email 1 AND email 2 is sent.  This is Incorrect as only email 1 should be sent

2-If the location is anything other than Perrysburg or Bridgwater, email 2 is sent.  This is Correct!

 

#1 

@AND(
equals(body('Get_item')?['Status'],'Pending HR Approval'),
OR(
equals(body('Get_item')?['Internship_x0020_Location']?['Value'],'Perrysburg'),
equals(body('Get_item')?['Internship_x0020_Location']?['Value'],'Bridgwater')
     )
)

 

#2

@AND(

equals(body('Get_item')?['Status'], 'Pending HR Approval'),

OR(

not(equals(body('Get_item')?['Internship_x0020_Location']?['Value'], 'Perrysburg')),

not(equals(body('Get_item')?['Internship_x0020_Location']?['Value'], 'Bridgwater'))

     )

)

Re: Using AND/OR in same condition

@H-F Please share a screen shot of the parrallel branch if possible.

H-F
Level: Powered On

Re: Using AND/OR in same condition

Flow1.jpgFlow2.jpg

I'm not sure I can or how it would be helpful to you. The flow scrolls off my screen to the right and you can't see much of the condition because the box is so small.

Is there anything else I can tell you to help?  What would I need to change in the conidtions to make it work?

Re: Using AND/OR in same condition

Hi @H-F,

 

1. Do not use parallel branch for this.

2. This is a simple case where: Using case 1 as you mentioned will do the work:

#1 

@AND(
equals(body('Get_item')?['Status'],'Pending HR Approval'),
OR(
equals(body('Get_item')?['Internship_x0020_Location']?['Value'],'Perrysburg'),
equals(body('Get_item')?['Internship_x0020_Location']?['Value'],'Bridgwater')
     )
)

 

3. Add the above condition in "IF" condition, if result is "YES" send "Email1" , for result "NO"  send "Email2".

4. Remove Parallel branch.

 

Let me know for queries, if not clear.

 

Regards,

Chandrashekhar,

Pune, India.

Dorul
Level 8

Re: Using AND/OR in same condition

Hi @H-F

Just a small advice, regarding your printscreens.

You can hold CTRL and move mouse wheel to make your flow smaller.





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





H-F
Level: Powered On

Re: Using AND/OR in same condition

Thanks for the tip!

H-F
Level: Powered On

Re: Using AND/OR in same condition

Thank you for your response.  The problem is that if I put this into the No part without a condition, this is triggered for other status' (i.e. Status=Denied which I have another branch for).  If I add a condition then I'm in the same boat of not being able to get the condition formula to work.

Can you take a look at my 2 formulas and tell me what's wrong with them?  Why doesn't #1 work?

 

How it currently works with the formulas below:

1-The problem is that if the location is either Perrysburg or Bridgwater, both email 1 AND email 2 is sent.  This is Incorrect as only email 1 should be sent

2-If the location is anything other than Perrysburg or Bridgwater, email 2 is sent.  This is Correct!

 

#1 

@AND(
equals(body('Get_item')?['Status'],'Pending HR Approval'),
OR(
equals(body('Get_item')?['Internship_x0020_Location']?['Value'],'Perrysburg'),
equals(body('Get_item')?['Internship_x0020_Location']?['Value'],'Bridgwater')
     )
)

 

#2

@AND(

equals(body('Get_item')?['Status'], 'Pending HR Approval'),

OR(

not(equals(body('Get_item')?['Internship_x0020_Location']?['Value'], 'Perrysburg')),

not(equals(body('Get_item')?['Internship_x0020_Location']?['Value'], 'Bridgwater'))

     )

)

 

Re: Using AND/OR in same condition

Hi @H-F,

 

Change formula 2 to as below:

 

#2

@AND(

equals(body('Get_item')?['Status'], 'Pending HR Approval'),

AND(

not(equals(body('Get_item')?['Internship_x0020_Location']?['Value'], 'Perrysburg')),

not(equals(body('Get_item')?['Internship_x0020_Location']?['Value'], 'Bridgwater'))

     )

)

Keep formula 1 as it is.

 

Check and let me know.

 

Regards,

Chandrashekhar

Highlighted
H-F
Level: Powered On

Re: Using AND/OR in same condition

This worked, thank you!

As soon as I saw it, I knew you were right but I just could not get it.

Re: Using AND/OR in same condition

Hi @H-F,

 

You are welcome.

 

Happy to help. Even i am in learning mode.

 

Regards,

Chandrashekhar

Pune, India.

Spacuvate123
Level: Power Up

Re: Using AND/OR in same condition

Hi,  this condition is not executing Correctly.

 

@AND(contains(items('Apply_to_each_Attachment_on_the_email')?['Name'], 'txt'),
OR(contains(items('Apply_to_each_Attachment_on_the_email')?['Name'], 'xlsx')))

Re: Using AND/OR in same condition

Hi @Spacuvate123,

 

1. Mistake - AND/OR can be applied on two statements.   you are using both at the same time.

 

2. Solution:

 

AND :

 

@AND(contains(items('Apply_to_each_Attachment_on_the_email')?['Name'], 'txt'),
(contains(items('Apply_to_each_Attachment_on_the_email')?['Name'], 'xlsx')))

 

OR :

 

@OR(contains(items('Apply_to_each_Attachment_on_the_email')?['Name'], 'txt'),
(contains(items('Apply_to_each_Attachment_on_the_email')?['Name'], 'xlsx')))

 

Please test and let me know for issues.

 

Regards,

Chandrashekhar

Pune, India.

 

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow 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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 81 members 3,435 guests
Please welcome our newest community members: