Power Automate: Cloud Flows + Trigger Conditions | Preventing Unnecessary Runs


The ask? Create a SharePoint Online (SPO) document set, titled “Binder,” with a complex structure of nested folders and files. Now, document sets aren’t ideal for deeply nested directories, but the client isn’t budging.

Part 1 of the solution? Leave the document set’s default content empty and instead, copy the 50+ child folder structure to a new document library, using this secondary library as a “template” source.

Next, create a Power Automate cloud flow and select the SPO trigger When a file is created (properties only), then include a Copy folder action. Now, when someone creates a new “Binder,” the cloud flow will trigger and copy the complex folder structure from the “template” library to the newly created “Binder” item.

Figure 1 - Power Automate cloud flow to copy folder from a source to a target.
Figure 1 – Power Automate cloud flow to copy folder from a source to a target.

Unfortunately, this comes with a wrinkle. Per the trigger logic, the flow will run every time a file is added to the library. People could upload anything and with 50+ folders per “Binder,” this could result in hundreds, if not thousands of unnecessary runs. That Microsoft bill would not be pretty.

Part 2 of the solution? Add a trigger condition, ensuring that this flow only runs when a new item with the ContentType name of “Binder” is created:

  • @equals(triggerBody()?[‘{ContentType}/Name’], ‘Binder‘)
Figure 2 – Power Automate cloud flow trigger Settings.
Figure 3 - Power Automate cloud flow trigger Settings with Trigger conditions.
Figure 3 – Power Automate cloud flow trigger Settings with Trigger conditions.

Conclusion:
Creative solutions often require additional considerations. The “template” library makes managing the complex folder structure easier but introduces the wrinkle of wasteful flow funs. Trigger conditions are the extra safety measure to preventing unnecessary cloud flow runs and unexpected billing costs.

“If not us, then who? If not now, then when?”

John Lewis

#BlackLivesMatter

Leave a comment