How to find all associated Power Automate Flows for a SharePoint list?

Summary

A customer showed a working Power Automate for an item created trigger. There was an approval action in the flow so technically only one email should be sent for a new item. But she noticed multiple approvals emails were sent. This was no way possible.

Our suspicion was there may more than one flow associated to the list. What if, this flow was duplicated by someone and that also started running for an item created event.

The question is, how do we find out how many flows are associated to the list?

The answer is to make a call to the SyncFlowInstances to the list to find all associated Power Automate Flow.

Step By Step solution

Step #1 First, create a Manually Triggered Power Automate Flow.

Step #2 Add “Sent an HTTP request to SharePoint” action

Make a call to SyncFlowInstances

Copy paste values to your ” Sent an HTTP request to SharePoint” action. Make sure to change the list name below, my list name is MasterSiteInventory yours may be different.

Site Address: [Your Site]

Method: POST

Uri:

_api/web/lists/GetByTitle('MasterSiteInventory')/SyncFlowInstances

Headers:

{
  "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose"
}

Body: EMPTY

The above call returns a response in the FlowSynchronizationResult. The intent now will be to get the data from the FlowSynchronizationResult.SynchronizationData property. This property stores value as JSON string as seen in the below sample data.

{
  "d": {
    "__metadata": {
      "id": "https://BLAHBLAH.sharepoint.com/sites/siteprovisioning-preprod/_api/web/lists/GetByTitle('MasterSiteInventory')/SyncFlowInstances",
      "uri": "https://BLAHBLAH.sharepoint.com/sites/siteprovisioning-preprod/_api/web/lists/GetByTitle('MasterSiteInventory')/SyncFlowInstances",
      "type": "SP.FlowSynchronizationResult"
    },
    "SynchronizationData": "{\"value\":[{\"name\":\"1a7", REMOVED FOR BREVITY"
    "SynchronizationStatus": 0
  }
}

Step # 3 Now parse and convert the above SynchronizationData JSON string to HTML

Add a Compose action with the following formula. As you can see the data is converted first to JSON and then we access the value property. The value property is a JSON array.

json(outputs('Send_an_HTTP_request_to_SharePoint')?['body']?['d']?['SynchronizationData'])?['value']

Step # 4 Now iterate the value JSON array to select name and display name.

From

outputs(‘Compose’)

Map

{
  "ID": {@item()?['name']},
  "Name": {@item()?['properties']?['displayName']}
}

Step # 5 Now, just take the output of select and pass to Create HTML

Conclusion

Using the above method you can quickly find out how many flows are associated on your list.

Here was my output for the above flow.

My inspiration to write this blog is from the below article.

How to get a list of Flow instances attached to a SharePoint List?

Unknown's avatar

About Pankaj

I am a Developer and my linked profile is https://www.linkedin.com/in/pankajsurti/
This entry was posted in Power Apps, Power Apps, Power Automate. Bookmark the permalink.

12 Responses to How to find all associated Power Automate Flows for a SharePoint list?

  1. Chaitra B C's avatar Chaitra B C says:

    For some reason the API call returns 0 results. Please advise.

  2. Craig's avatar Craig says:

    This really helped me out man. Thank you.

  3. Jean-Paul's avatar Jean-Paul says:

    Still works? Cause I’m getting errors… and i need this so much, please

  4. Pushyami's avatar Pushyami says:

    I get only personal productivity flows data that too the trigger is sharepoint related. If I create scheduled or instant flows that data is not coming up. any idea how to get the environment name and associated flows

    Thanks in advance!

  5. OliverR-82's avatar OliverR-82 says:

    None of my sites seem to have a list called MasterSiteInventory. If I google “SharePoint MasterSiteInventory” the only search result is this post. Doesn’t seem like it’s a list that is documented anywhere.

    • Weblin's avatar Weblin says:

      That is their list name, you substitute that for the list you want to get the flows for.

      • OliverR-82's avatar OliverR-82 says:

        That makes so much sense that I don’t understand why I didn’t understand it when I first read the article, lol. Thanks for pointing this out to me. Got it working now, cheers!

  6. Ash's avatar Ash says:

    In the select action I’m getting enter valid JSON error for this:
    {
    “ID”: {@item()?[‘name’]},
    “Name”: {@item()?[‘properties’]?[‘displayName’]}
    }
    Please let me know what’s wrong?

    • Ephrem's avatar Ephrem says:

      { “ID”: “{@item()?[‘name‘]}”,

      “Name”: “{@item()?[‘properties‘]?[‘displayName‘]}” }

    • Arik's avatar Arik says:

      You need to remove the starting {@ and } from the last JSON code.

      The correct expression to use is

      item()?[‘name’]

      item()?[‘properties’]?[‘displayName’]

      This will work!

  7. LKS's avatar LKS says:

    I also ran into the “enter valid JSON” error.

    It appears Power Automate thinks there can be multiple entries for [‘value’], so it won’t grab anything out of [‘value’] without an Apply to each loop.

    There might be a better way to do this without all the Composes, but here’s what worked for me after much fiddling about:

    1. Manually trigger a flow

    2. Initialize variable
    — make this an Array, you can name it anything you like, I named mine “Results”
    — leave the value blank

    3. Send an HTTP request to SharePoint — using all the steps in the guide above

    4. Compose
    — Rename this step to something unique like “Compose – HTTP request Body”
    — Put in the “Body” output from the prior step “Sent an HTTP request to SharePoint”

    5. Compose
    — Rename this something unique like “Compose – JSON from HTTP request”
    — Use this expression:
    json(outputs(‘Compose_-_HTTP_request_Body’)?[‘d’]?[‘SynchronizationData’])

    6. Apply to each
    — Use this expression:
    outputs(‘Compose_-_JSON_from_HTTP_request’)?[‘value’]

    7. Compose (Inside Apply to Each)
    — Rename this something unique like “Compose – ID”
    — Use this expression:
    items(‘Apply_to_each’)?[‘name’]

    8. Compose (Inside Apply to Each)
    — Rename this something unique like “Compose – displayName”
    — Use this expression:
    items(‘Apply_to_each_-_value’)?[‘properties’]?[‘displayName’]

    9. Append to array variable (Inside Apply to Each)
    — Name: (the name of the variable you setup in step 2). I named mine “Results”
    — Value:
    {
    “ID”: outputs(‘Compose_-_ID’) ,
    “Name”: outputs(‘Compose_-_displayName’)
    }
    — for the outputs(‘Compose… add these as expressions
    — don’t forget the comma at the end of the ID line

    10. Compose (Not in apply to each)
    — Use the variable you created in step 2 and added info to in step 9. I named mine “Results”

  8. Arik's avatar Arik says:

    Thank you for this blog. It works like a charm!!

Leave a reply to Jean-Paul Cancel reply