Forum Discussion
Issues with a Power Automate flow running multiple times
Hello Guys,
I have a power automate flow that does the following :
- Triggers when a file is uploaded to a "Working documents" library. I have put a trigger condition whereby It triggers only when the "document department" column for the uploaded file is set to either HR, or Finance etc (if the dept column is blank, it doesn't trigger).
-The flow then gets the "document department" value of the uploaded file in the library, matches it with a lookup list called "Departments", which is then used to grab the department code (For eg, the dept code for Human resources is "HR", and for Financial control, its "FC").
-Then once the department code is fetched, the main goal of the flow is to set the "document number" column in the library to auto increment for each uploaded file. (For EG if dept of uploaded file is Human resources, the flow gets the code "HR" and concatenate it with "00X" where x is the incremental number. So if I upload a file for HR department, the first document for HR would get the name "HR001", and next one would be "HR002" etc. If dept is finance then that code is fetched and doc number is populated with FC001, etc.
The above flow works, and the "document number" is being populated. But the Flow keeps running over and over again. So if I upload a file for HR (and if document number is HR001, then after a while the same document number for that file keeps increasing to HR010....HR 011....etc).
I am not sure why the flow keeps running. Here is some information :
-The departments list (that the "Document department" column in the library is looking up to :
Here is the doc library where I am uploading files (and populating the "document Department column" after uploading the file. Notice that the flow updates the "doc number" column when flow runs. But the number keeps increasing:
Here is the trigger for the flow (I renamed it but the trigger was "When a file is modified in list/library"):
this is the trigger condition for above step
Next step in flow is to filter the department list where the title(Department) is equal to the doc department column in the library (using filter query here)
Then I am initializing some variables for document count, and format. Then concatenating the "department code" value and the "000" number format , then updating the document count
Can you pls advice why the doc number keeps increasing? Is it because I am using a wrong trigger ? or is flow going into a infinite loop or something
- Jon_LakeBrass Contributor
HI vassp1980 , if your trigger is 'on change' that can result in a Flow entering a perpetual loop. I suggest you add a 'yes/no' field and have your update action change it to 'yes'. Your trigger can then run, and any get items action which follows can use a query filter to exclude those items where the update field is 'yes'. You could then use a condition to evaluate the items returned and continue the Flow.