Reuse Flows connected to SharePoint Lists


When working with SharePoint, Power Automate brings a great set of actions to improve day-to-day processes. You can automate work by creating flows that:

  • Start approval processes or request signatures
  • Perform analysis using AI builder technologies
  • Trigger processes depending on metadata changes

Building these types of solutions can save a lot of time for people in organizations, but what about saving time on development?

Imagine this scenario: you work in a Marketing department with 10 document libraries having the same requirement; every file needs a flow that changes the status and moves it to the Completed folder.

At first glance, this might seem like a simple task. However, you would need to create the same Flow for each library. What if later on, there is a change in the requirements? Or a new status appears, or we need to add another step to our Flow? Maintaining these Flows can be a challenging task.

Let’s see how we can reuse the same Flow for different document libraries. Keep in mind that this approach works the same on Lists or Document libraries.

Build your Flow

The first step is to create an Instant Flow. I’m going to use the sample requirements to build it.

  • Go to Power Automate, create an Instant Flow, and Select For a selected File as the trigger. Choose the Marketing site and one of the document libraries.
  • Add an Update file properties action to set the status as Completed.
  • Move the file to a Completed folder inside the library.

Your Flow should end up like this:

Flow actions
Brochure process Flow

Reuse your Flow

Right now, the Flow is connected to the document library that has been set in the trigger, and it is available through SharePoint’s Automate toolbar:

On Flow execution, the trigger action gets information about the selected file that started the Flow: ID, URL, Filename, and the File ID. However, we also need information about the site and the document library.

    "body": {
        "entity": {
            "ID": 12,
            "itemUrl": "",
            "fileName": "Brochure (1).pdf",
            "FileId": "12"

We could dissect the itemUrl, but SharePoint sometimes gives you another URL type, for instance:

Digging a little more, in the trigger data’s headers section, we could see a property called Referer that gives us two essential parameters: the SharePoint site and the List ID.

    "headers": {
        "Connection": "...",
        "Accept": "...",
        "Accept-Encoding": "...",
        "Accept-Language": "...",
        "Expect": "...",
        "Host": "...",
        "Referer": "",
        "User-Agent": "...",
        "x-ms-client-session-id": "...",
        "x-ms-client-request-id": "...",
        "origin": "...",
        "sec-fetch-site": "...",
        "sec-fetch-mode": "...",
        "sec-fetch-dest": "...",
        "X-MS-APIM-Referrer": "...",
        "x-ms-gateway-object-id": "...",
        "X-MS-APIM-Tokens": "...",
        "X-MS-APIM-Referrer-Prefix": "...",
        "X-MS-APIM-Callback": "...",
        "x-ms-user-id": "...",
        "x-ms-user-name": "...",
        "x-ms-user-name-encoded": "...=",
        "x-ms-user-email": "...",
        "x-ms-user-email-encoded": "...",
        "x-ms-user-timestamp": "...",
        "X-Forwarded-For": "...",
        "Content-Length": "...",
        "Content-Type": "..."
    "body": {
        "entity": {
            "ID": 12,
            "itemUrl": "",
            "fileName": "Brochure (1).pdf",
            "FileId": "12"

Using these parameters, we can detect from which site and from which list we are being called. To get this data, we are going to use the trigger() function as it returns all the information regarding the Flow’s caller.

To extract this information, we are going to use three compose actions to get:

Referer URL


SharePoint Site URL

decodeUriComponent(first(split(last(split(outputs('Referer'), '')),'&')))

SharePoint List ID

first(split(last(split(outputs('Referer'), 'parameters.sharepoint.list=')),'&'))

We can then use these outputs to get information from the list items or document library files. For instance, by using Custom values in Get file properties actions, in addition to the ID received in the trigger.

Putting in all together

Now that the Flow is library agnostic, we need a way to call it from the other document libraries. Using the toolbar’s Automate option is only available for library configured in the trigger of the Flow.

This is where SharePoint Column formatting comes to the rescue. It allows you to transform the render of any given list view column. Therefore, giving you the ability to display the data exactly the way you want it.

One of the features included is the ability to call Power Automate Flows using a custom row action called executeFlow. You only need to provide the Flow ID, which you can get by opening your Flow and looking at this portion of the URL:<environment-id>/flows/<flow-id>/details

To use it, add a calculated column in your document library with a dummy formula like this: =””. After that, format this column in your view to call the Flow. For example:

  "$schema": "",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"026a443e-d394-4457-b291-5134a981f90c\"}"
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  "children": [
      "elmType": "span",
      "attributes": {
        "iconName": "Completed"
      "style": {
        "padding-right": "6px"
      "elmType": "span",
      "txtContent": "Mark as complete"

Your Document library will be able to call the Flow through a button:

SharePoint column formatting.

Add this column to the rest of the document libraries and then, they all will be calling the same Flow. Sending the ID of the file that requested it along the way.

You can get the Flow that dissects the SharePoint parameters from my GitHub repository.

I hope this approach helps you with your Flow maintenance tasks ✌


  1. Reply

    Hi Eickhel,
    Thank you so much for this solution!
    I have one problem at the end of the process, when i upload a file.
    When I insert a new file I have some more column with information, if I try to save after the update , SP return me that i can’t save it due to a validation error…. it’s something familiar for you?

    Thank you

    1. Reply

      Hi Riki,

      It depends on the validation error youbare getting.

      What’s the error?

      1. Reply

        Hi Eickhel,
        I solved it by changing the formula to: =1<2
        Probabbly is related to the double qoute that we don't use here for string.
        Thank you for your answer.

Leave a Reply

Your email address will not be published. Required fields are marked *