cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gjayne84
Frequent Visitor

AND OR in same expression

I've seen a couple of posts on this subject but I just can't get it to work.  Basically I want to add an if statement along the lines of:

 

IF Created Date = Modifed Date OR (Document Type is not blank AND Date is not blank AND reference is not blank)

 

In Flow I've added the following expression in the condition step:

 

@or(
equals(triggerBody()?['Created'], triggerBody()?['Modified']),
and(
not(empty(triggerBody()?['Document_x0020_Type'])),
not(empty(triggerBody()?['Date_x0020_of_x0020_Work'])),
not(empty(triggerBody()?['Property_x0020_Reference']))
)
)

 

However, this doesn't work and items that should pass this test aren't.  Am I using the correct syntax?

 

I'd be grateful for any assistance anyone can give.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

Hi @gjayne84,

 

I tested your formula and found it to be correct. I was wondering if you configured the wrong Trigger. If you are using When an item is created, then this condition will always be true.

I did a test on my side, using When an item is created or modified as the trigger, and then using the your formula. It work fine.

The configuration of the SharePoint list's Column, only Date of Work is the Date and time type, the others are Single line of text:

46.PNG

Can you share your Flow configuration?

I have other formulas you can use here, and Trigger still uses When an item is created or modified.

@or(equals(triggerBody()?['Created'], triggerBody()?['Modified']),and(not(equals(empty(triggerBody()?['Property_x0020_Reference']), true)),not(equals(empty(triggerBody()?['Document_x0020_Type']), true)),not(equals(empty(triggerBody()?['Date_x0020_of_x0020_Work']), true))))

Please try this again.

For more information on the usage of Expression, please refer to this link:

use-expressions-in-conditions

 

Best Regards,

Barry

Community Support Team _ Barry
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

2 REPLIES 2
v-bacao-msft
Community Support
Community Support

Hi @gjayne84,

 

I tested your formula and found it to be correct. I was wondering if you configured the wrong Trigger. If you are using When an item is created, then this condition will always be true.

I did a test on my side, using When an item is created or modified as the trigger, and then using the your formula. It work fine.

The configuration of the SharePoint list's Column, only Date of Work is the Date and time type, the others are Single line of text:

46.PNG

Can you share your Flow configuration?

I have other formulas you can use here, and Trigger still uses When an item is created or modified.

@or(equals(triggerBody()?['Created'], triggerBody()?['Modified']),and(not(equals(empty(triggerBody()?['Property_x0020_Reference']), true)),not(equals(empty(triggerBody()?['Document_x0020_Type']), true)),not(equals(empty(triggerBody()?['Date_x0020_of_x0020_Work']), true))))

Please try this again.

For more information on the usage of Expression, please refer to this link:

use-expressions-in-conditions

 

Best Regards,

Barry

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

Thanks @v-bacao-msft I've checked the flow again and I've found the issue.  The first test of Creted = Modified was failing my end because even though the dates were the same, the time was different by a few seconds.  I added formatDateTime() around each of the date fields to remove the time and this now works.

 

My next step is to try and resolve the issue of the flow running each time an individual field is modified on an item in the library.  For example, if I edit three fields on a document using modern edit form the flow runs three times.  The only way around this I've found so far is to go to Properties > Edit All for an individual document and then I can change multiple fields before clicking Save.

 

Thanks for your help with the if statement though, it was useful to get another pair of eyes look at it to make sure the syntax was correct.

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

Users online (2,094)