cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DS1
Level: Powered On

Flow running thousands of times on SP "When an item is created or modified"

Hello, 

I am hoping for some help on why a SharePoint Flow is running thousands of times - and a way to keep the functionality of the Flow, but stop it running constantly.

I got some help on creating a Flow, here:
https://powerusers.microsoft.com/t5/Building-Flows/Want-to-use-Flow-to-copy-data-from-one-list-colum...

The Flow works great, but it is running thousands of times, as in the analytics when items are not being created or modified:
Analytics.png

The reason behind the Flow is as such:

We have a calculated column called “Week Total” 

It is desired that “Week Total” be summed, but calculated columns in SharePoint cannot be summed.
We then have a Flow that will run on create or update that takes the value from "Week Total" and puts it into another column called "Sum" that can be summed.


The Flow steps are as follows 

  1. Under Flows> Microsoft SharePoint, choose: “When an item is created or modified” so that the action is triggered whenever an item is created or modified in the list
    (choose site address and list address)
  2. Choose “Compose” and enter the WDL Expression:
    int(triggerBody()?['Period_x0020_Total'])
    This triggers the change of text to number for the “Week Total” column
  3. The next action to add is “Update Item”
    (choose site address, list address, ID field and the required “Start Date” field
  4. Under “SUM,” our desired number column that can be summed, place the “Output” from the “Composed” action earlier
  5. Save Flow and enter a value into the Time Bank List to test
    (have tested with both updating and adding new values with success)

    Here is a picture:

Flow.png

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Flow running thousands of times on SP "When an item is created or modified"

Hi @DS1,

 

Could you please share a bit more about your SharePoint list?

 

I think there is something wrong with your “Update item” action, the “When an item is created or modified” trigger would be fired whenever an item is created or modified in the list. If you add an item or update existing item in your SharePoint list, the trigger would be fired and then the “Update item” action would update corresponding item in list. After that, the trigger would be fired again, because the “Update item” action has updated one item in SharePoint list. Your flow would be trapped in a infinite loop.

 

You could consider take a try to stop it running constantly with following workaround:

  • Add a “When an item is created or modified” trigger.
  • Add a Compose action, Inputs set to following formula:
int(triggerBody()?['Period_x0020_Total'])
  • Add a Condition, left input box set to dynamic SUM content, right input box set to output of “Compose” action, within middle drop down, choose is equal to.
  • Within “If/no” branch of Condition, add a “Update item” action, SUM field set to output of Compose action.

Image reference:9.JPGThe flow works successfully as below:10.JPG

 

11.JPG

 

 

Best regards,

Kris

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

5 REPLIES 5
Community Support Team
Community Support Team

Re: Flow running thousands of times on SP "When an item is created or modified"

Hi @DS1,

 

Could you please share a bit more about your SharePoint list?

 

I think there is something wrong with your “Update item” action, the “When an item is created or modified” trigger would be fired whenever an item is created or modified in the list. If you add an item or update existing item in your SharePoint list, the trigger would be fired and then the “Update item” action would update corresponding item in list. After that, the trigger would be fired again, because the “Update item” action has updated one item in SharePoint list. Your flow would be trapped in a infinite loop.

 

You could consider take a try to stop it running constantly with following workaround:

  • Add a “When an item is created or modified” trigger.
  • Add a Compose action, Inputs set to following formula:
int(triggerBody()?['Period_x0020_Total'])
  • Add a Condition, left input box set to dynamic SUM content, right input box set to output of “Compose” action, within middle drop down, choose is equal to.
  • Within “If/no” branch of Condition, add a “Update item” action, SUM field set to output of Compose action.

Image reference:9.JPGThe flow works successfully as below:10.JPG

 

11.JPG

 

 

Best regards,

Kris

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

Dual Super User
Dual Super User

Re: Flow running thousands of times on SP "When an item is created or modified"

Kris 

Thanx for the tip! I guess with your solution the Flow will be executed twice instead of entering an infinite loop, right?

 

@DS1There are several threads discussing this infinite loop effect like this one

https://powerusers.microsoft.com/t5/Building-Flows/Flow-update-to-SharePoint-list-item-fields-trigge...

 

I totally agree it is a limitation in Microsoft Flow. Let's hope Flow architects will find a solution to avoid it in the future. In the meanwhile, workarounds like the one described by @v-xida-msft are needed

 





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





DS1
Level: Powered On

Re: Flow running thousands of times on SP "When an item is created or modified"

Thank you so much for your help! I've had a chance to try the solution (which so far is workng very well) and will have a look on Tuesday as to the analytics and number of runs.

 

Really appreciate the support from the community and also to @efialttes

DS1
Level: Powered On

Re: Flow running thousands of times on SP "When an item is created or modified"

Thanks again, Kris - I've checked this morning and no more looping!

kurt3000
Level: Power Up

Re: Flow running thousands of times on SP "When an item is created or modified"

This seems to be somewhat related to my Flow and looping.  My source data is in SQL on-prem and I'm wanting to pull all rows from SQL in to a SharePoint Online list.  I'm able to run the initial SharePoint create items action which successfully creates the items in SharePoint i'm expecting.  In my condition below, the ProjectNumber array is checking for project numbers that have been created in my SP Online list then storing those in the array.

 

CreateItems.png

 

Each month, I will also need to update existing items in my SP Online list, as there are certain fields that will change from month-to-month.  Within the same condition, if ProjectNumber in SPO matches what's in SQL, I will run an update item and only update certain fields that are expected to change month-to-month.

 

UpdateItem.png

 

As to my data, I am expecting to loop through around 1000 rows of SQL data each month then update items in my SPO list that change in SQL.  For testing, I am applying a filter so I only get 6 rows of data back.  Here's what my data looks like:

 

Rows 1-6:

ProjectNumber, Project Name, AccountingDirector, ProjectAccountaint, ActiveStatus, CurrentPeriodBillings, PercentComplete

 

All of this data is mostly unique, such as ProjectNumber, ProjectName and a few other fields

 

When I run my Flow, I get all items in the SPO list and get all items in my SQL view

I have a condition that checks if my SPO project number contains my SQL project number

If No, create item (which works great)

if Yes, update all fields in my update items screen shot

 

The problem is when the Flow runs, all projects get updated with the same data 6 times

For example:

If I have Project 1234 and all of its corresponding data for my 1st project

Project 2345 and all of its corresponding data for my 2nd project

Project 3456 and all of its corresponding data for my 3rd project

Project 4567 and all of its corresponding data for my 4th project

Project 5678 and all of its corresponding data for my 5th project

Project 6789 and all of its corresponding data for my 6th project

 

When my Flow runs, all 6 items get updated with Project 1's data the first time around.  Flow repeats this loop process all 6 times and I can see on the 2nd loop that all 6 items get updated with project 2's data, etc.  This continues until the looping completes with the number of rows that are expected to be looped through.  In the end, all 6 items finally get updated with project 6's data then the Flow completes.

 

What I want is for only project 1 to get updated with its data, project 2 with its data and so forth.

 

Is this a bug within Flow, expected behavior or just a logic issue with my Flow.  Everything I've read seems to indicate the update item portion should work as what's in my screen shot.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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

Top Kudoed Authors (Last 30 Days)
Users online (4,917)