Triggering a single Flow from multiple SharePoint Lists or Libraries

One of the many great uses for Flow is to perform certain actions when an item is added to a SharePoint List or Library.  This is easy to achieve using the When a File is created or When an Item is created triggers.


However, what if you want to run the same Flow for triggers generated from multiple lists?  One option is to have one flow per list that will call the common flow.  Doable, but requires a lot of extra work and maintenance if the logic changes in any way.  What would simplify this process is an event that is easy to set up and configure on any list and library.

Using an Email-based trigger

In this example, I'm leveraging the Alerts mechanism that can be set up on each list or library to trigger a common flow.  The logic behind this approach is that when SharePoint sends an alert email on an item or document, it includes a link to the item and item ID, which are the key pieces of information you need.

Preconditions

To do so requires several things:

  1. Alert emails should be sent immediately
  2. Ideally, there should be a service account for all the flows
  3. The Alert Title needs to be consistent across all the lists for the flow


Flow breakdown

The Flow, depicted below, is broken down into 8 steps.


The first step is the trigger, which acts when an email arrives for the user account that is running the Flow.  Alert emails are generated from the no-reply@sharepointonline.com system account, so you can configure the trigger to only act on messages coming from that address.  Also, make sure to configure the Subject Filter to match the Alert Title you set on your list.

Steps 2 through 6 are mostly a text parsing exercise to extract the site URL, list URL, and item ID.  They are all embedded in the email body.  Step 3 helps clean up all the HTML tags, thus making it a bit easier to parse out the elements.

Once you have your item ID and link, you're all set to get the item (step 7) and do with it as you wish.  Optionally in step 8, you can delete the alert email if you have no other use for it.

4 comments:

  1. Can you add any details on what strategy you used to extract your data?

    ReplyDelete
  2. I was using the standard alert email and was parsing it out.

    ReplyDelete
  3. Haniel, you are a genius! This a really great solution. I was able to delete 30 or so copies of my flow and now I only I have run one for the whole site! Absolutely brilliant. Thank you so much for this!

    ReplyDelete

Employee Check-in Simplified using Power Automate

Company employees who move between offices are often faced with a tedious process of having to check-in at the security desk to get a tempor...