cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

A laymans solution to infinate loop problem with ''When an Item is Created or Modified''

Hi all, I'm writing this comment after succesfully stopped a loop in ''When an item is created of modified''. As I'm a newbie to Flow this took a lot of time to get the logic correct. I hope that this comment might help others, so let's go.

 

TLDR; Write Trigger Conditions for the ''When an item is created or modified'' and add these blockers with ''Update Item''. You can create hidden colums for the list if you need more blocker data.

 

Background: When a new item is added to a list or an existing item is modified, an email needs to be sent and the item gets new meta data. Ok, doens't sound that difficult? Well..

 

Paradox: The new meta data will trigger the flow once again, causing a loop, this we know.

 

Case triggers: for this particular flow the triggers are: ''Delivery date < today & Send = true & OrderID = false'' we identified that the trigger ''delivery date < today'' where the cause of the loop, the other two triggers we could block with new meta data on the item.

 

Solution: in the settings for ''When an item is created of modified'' you have options to set Trigger Conditions, after some testing we  could determinate that each row of Trigger Conditions where ''AND'', not ''OR''. Therefore the ''OR'' needed to be in the same row, here's our 1st condition:

 

@or(or(lessOrEquals(triggerBody()?['Svea_Order_Date'], utcNow()), equals(triggerBody()?['Send'], true)), equals(triggerBody()?['Order_ID'], ''))

 

 

 Ok, we've now blocked 2/3 of the triggers, the date < today still causes a loop. This got solved by utilizing the ''AND'' relationships between the rows of the Trigger Conditions. This is the condition:

 

@equals(triggerBody()?['Skickad'], false)

 

 

Though our list didn't have a metadata showing if an email has been sent or not, so we created a hidden column called ''Sent = YES/NO'' with ''NO'' being the standard value. With this we can update our metadata to YES and therefore blocking all triggers when the item is modified.

 

The end result of the trigger conditions looks like this.

 

@or(or(lessOrEquals(triggerBody()?['Svea_Order_Datum'], utcNow()), equals(triggerBody()?['Skicka'], true)), equals(triggerBody()?['Order_ID'], ''))

 

there's a native ''AND'' relationship between these two rows.

 

@equals(triggerBody()?['Skickad'], false)

 

 

 

 

 

 

 

 

 

Can't figure out how to add pictures to this post.. sorry..

 
0 REPLIES 0

Helpful resources

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,701)