Can I use one Microsoft Flow for multiple libraries?
Yes, you can use one Microsoft Flow for multiple libraries, but you need to “Save As” each time, which makes them separate, non-connected Flows. It also means you need to update your metadata each time, and more importantly, if you make a change in one – it won’t apply across all 5, 10, or 100 libraries that you’re using this Flow in.
Let’s say I have a Document Library approval that I want to run. Not ALL libraries need it, but many do. I’ve been using my ‘Very Complicated Flow’ on one Library for a while – it’s over 100 actions, has complex conditions and analysis within it. It has a very thorough set of states within it for each level of approval and what actions to take.
What if I was just requested to apply this to another 50 libraries, due to the benefits it offers. I know I can use “Save As” to other libraries, but what if I need to add or remove a state? I suddenly have to update these other 50 library Flows!? No, thank you!
Use one list to act as the Flow kick-off, and use this to kick off your main, ‘Very Complicated Flow’!
This will not limit the amount of Flows you use – you will still need at least one per library, but you will only need one of your ‘Very Complicated Flows’.
We start off with one library: ‘ImportantDocuments1‘. I’ve built a pretty basic library here, with an ‘Approver’ column, and a column to identify if it ‘NeedsApproval’: yes or no.
Our demonstration Flow to be the “dummy” for a complicated Flow is aptly named ‘VeryComplicatedDocumentLibraryFlow‘. When we start, before knowing how many other libraries we’ll need to control, we have ‘ImportantDocuments1‘ as the trigger for this workflow.
I save, and my ‘VeryComplicatedDocumentLibraryFlow‘ is large and wonderful and perfect. For this one library.
But, OH NO! It is three months later and we have determined that another library, ‘ImportantDocuments2‘ requires this same Flow!
Well, I could Save As and reconnect it … but that means if I need to update some part of the Flow, I will have to do it twice – once for each Flow. And sure that’s easy if there’s only two – but what if we need this for 10 more libraries? Or 50?
And so… let’s try a different way.
Yes, we will need to re-architect our Flow a bit – but we should keep this in mind going forward for repeatable Flows.
The first thing I’m going to do is create a ‘ListToHoldImportantDocumentLibraries‘. This list will hold a Title, a ListID, and an ItemID. All of these are single lines of text. Next, I’m going to create a Flow – and this one will need to be ‘Saved As‘ each time, unfortunately, but bear with me – there is a benefit.
This Flow will add the required data for your ‘Very Complicated Flow’ to this list when a new document is added to a library (‘ImportantDocuments1’). Since it’s only a single action Flow, as opposed to your ‘Very Complicated Flow’, which may have scores of actions, it’s much easier to update. Plus, due to its simplicity, it’s unlikely you’ll ever need to update it.
Here’s what that Flow will look like:
As mentioned, we just want to track the Title (mostly for our own reference), the ListID, and the ItemID. So we are typing the ListID and Title right on in there, and adding the ID from the document that triggered the Flow.
Let’s test this and make sure it works… I upload a file into ‘ImportantDocuments1’:
The Flow runs and generates this entry in my management list:
Great! Now, back to our ‘Very Complicated Flow’.
It’s going to need a bit of a makeover – but, depending on your Flow, hopefully only of the first trigger item.
I’ve changed mine from watching ‘ImportantDocuments1‘, to watching a list: ‘ListToHoldImportantDocumentLibraries‘! Can you see where this is headed?
To get us back to the same starting point we had with our original ‘Very Complicated Flow’, we will need to use an HTTP request. I think this is the fastest way:
This request looks at whatever library title we’ve given it (the variable will now hold that information. Thanks, other list!), focus in on the ID that we’ve identified within that library, and pull back all the columns associated with it.
Once this is done, we will have everything we need to reconnect the entirety of the Flow and have this one Flow run for all Document Libraries, where any changes we make in this Flow will apply to all libraries.
If you’re not sure how to read and use the data that came out of the HTTP Request, follow these simple steps: run your workflow once, and once it’s complete, go to workflow summary and view the Body of the HTTP request.
Copy everything in there!
Add a Parse JSON action in your workflow right after your HTTP Request, identify ‘Body’ from the previous action to input to the Content field, and then click on ‘Use Sample Payload to Generate Schema’, paste in the ‘Body’ you copied, and click done.
Now, when you want to use data from the document for your next actions, they will be available through the Parse JSON. (I always rename this action so I can keep track of what has been parsed! For example, I have called this ‘OriginalDocumentMetadata’.)
Here’s an example: I can see the ‘NeedsApproval’ column data and pull it directly into a condition! Whoa!
Note that my ‘Approver’ has been split out into a StringID and an ID, due to the nature of the field type (Person).
That’s it! You can now use one Microsoft Flow in multiple libraries!
Have more questions? Elantis is the leader in Digital Transformation and offers Business Process Automation, Business Intelligence and Enterprise Content Management services. Reach out to Elantis’ Flow experts today.
Rhia is a Business Process Automation expert and one of the few Nintex virtual Technology Evangelists (vTE) in the world. Her experience defining, implementing, and enhancing processes, governance, and Information Architecture has garnered industry recognition. Rhia has spoken at industry events throughout Canada and the United States.
Edmonton, Alberta — Dec 3, 2019 — Elantis Solutions Inc. announced that it is the only company in the world with two Nintex virtual Technical Evangelists (vTEs) on staff. There are only three vTEs in Canada – and less than sixty in the world – making this a unique competitive advantage for Elantis.
What are the digital transformations trends shaping 2020? Let’s unpack a couple of these and understand where you can stay ahead of the technology curve.
You need cost effective IT solutions to provide real ROI as quickly as possible. Can you use a configurable solution to save money on your intranet deployment?