cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SamBasso
Helper I
Helper I

Infinite loop

I have list A and list B.

 

Trigger 1: When item is created in list A it populates a couple fields into list B (category, price).

Trigger 2: Update a couple of calculated fields in list B depending on (category, price) values using values in reference list C.

 

Since list B is updating itself, I am getting an infinite loop.

 

I want to use the Trigger Conditions in Settings for the Trigger - and this would ideally be on some timestamped fields (UtcNow?) but can't seem to put the pieces together.  It must exist but haven't found a resource that explains this so clearly that I can put into practice.

 

I don't want to use a separate account for handling the flows as my solution.

 

Any pointers would be useful as I am just about pulling my hair out with Flow.

1 ACCEPTED SOLUTION

Accepted Solutions
SamBasso
Helper I
Helper I

Ok so basically (answering my own question).... 

 

I don't think that using timestamps to determine whether the flow should be triggered or not, in this case was appropriate.  I have two Flows (flow B triggered when flow A has run) that each would have timestamps as to when they were modified.  I have no control over how quickly the flows will run, this may change. It just seemed a bit chancey.

 

It was not my original intention but in the end I created a service account to manage the flow. I think this really is the only way to control this behaviour clearly.  I took the following actions;

Created LastModifedBy field in SharePoint List B.

Flow A populates LastModifiedBy column in List B with the Modifed By Email.

Flow B also populates LastModifiedBy column in list B with the Modified By Email value.

- Added trigger condition to Flow B to only run if the value for the LastModifiedBy field <> the service account email.

@not(equals(triggerOutputs()?['body/LastModifiedBy'],'service-account@yourdomain'))

That's it. It works.

 

For reference, I found this video by Reza Dorrani really useful and very clear:

https://www.youtube.com/watch?v=oKN4_5o2NUA

 

I also referred to this article which was quite useful (you may want to use the time stamps approach instead if more suitable);

https://medium.com/@gurdevluck/prevent-infinite-loop-in-microsoft-flow-power-automate-b3cf9d764926

 

There may be better options to manage your flow as you want.  Feel free to add here.  I am new to PowerAutomate. so just feeling my way in as to what seems most logical.

 

Sam

 

 

View solution in original post

3 REPLIES 3
SamBasso
Helper I
Helper I

Ok so basically (answering my own question).... 

 

I don't think that using timestamps to determine whether the flow should be triggered or not, in this case was appropriate.  I have two Flows (flow B triggered when flow A has run) that each would have timestamps as to when they were modified.  I have no control over how quickly the flows will run, this may change. It just seemed a bit chancey.

 

It was not my original intention but in the end I created a service account to manage the flow. I think this really is the only way to control this behaviour clearly.  I took the following actions;

Created LastModifedBy field in SharePoint List B.

Flow A populates LastModifiedBy column in List B with the Modifed By Email.

Flow B also populates LastModifiedBy column in list B with the Modified By Email value.

- Added trigger condition to Flow B to only run if the value for the LastModifiedBy field <> the service account email.

@not(equals(triggerOutputs()?['body/LastModifiedBy'],'service-account@yourdomain'))

That's it. It works.

 

For reference, I found this video by Reza Dorrani really useful and very clear:

https://www.youtube.com/watch?v=oKN4_5o2NUA

 

I also referred to this article which was quite useful (you may want to use the time stamps approach instead if more suitable);

https://medium.com/@gurdevluck/prevent-infinite-loop-in-microsoft-flow-power-automate-b3cf9d764926

 

There may be better options to manage your flow as you want.  Feel free to add here.  I am new to PowerAutomate. so just feeling my way in as to what seems most logical.

 

Sam

 

 

View solution in original post

Hello Sam,


Glad to hear you were able to find a solution that works and another thank you for the details on how you found your solution with links. Based off the information you provided having your trigger be so that it confirms conditions to continue would be the best option.

 

One suggestion would be to base it off a value that is set for a column not based of email addresses. This is because depending on your flow it may have dozens of different names used and could add additional confusion, whereas if you used a boolean that only has 2 values to choose from you would be able to even setup your flows to update it to a True/False depending on what it is the flow is doing thus giving more control of how it reacts down the line to changes.

Hi Brayden,

 

Thanks so much for your reply.  When you put it like that it makes it sound so simple. 

 

I tried your method and in the end it was v simple.  Going back to the original post;

I have list A and list B. 

Actions taken:

1. Added column called 'TriggerTheFlow'  to list B.  This was single line of text, not Yes/No field.  Will explain why later.

2. I modified the Trigger Condition in Settings to;

@equals(triggerOutputs()?['body/TriggerTheFlow'],'Yes'

 

Flow behaviour;

Trigger 1: When item is created in list A it populates a couple fields into list B (category, price). <-- TriggerTheFlow field populated with 'Yes'.

Trigger 2: Update a couple of calculated fields in list B depending on (category, price) values using values in reference list C.  <-- TriggerTheFlow field updated to 'No'

 

The flow runs just once and solves the looping issue (and without need to operate as a service account as Brayden mentioned).

 

Note; I originally added the TriggerTheFlow as Yes/No column in SharePoint list B but had issues with looping still.  Not sure why but could well be my Trigger Condition code, which was:

@equals(triggerOutputs()?['body/TriggerTheFlow'],'true')  

 

Thanks Brayden for the insights.

 

Sam

 

Helpful resources

Announcements
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

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (33,411)