“I’d like to reuse my Power Automate flow on a different SharePoint site, is there some easy way how can I reconnect all the lists without updating all the actions one by one?”
When you build Power Automate flows, the right approach should be to have two environments. One where you’ll develop the flow and do all the testing, and a second one for the final flow. If it’s a flow connected to SharePoint, it might be two SharePoint sites. One with testing data, another one with the production data. Only properly tested flows should make it to the production data.
Yet if you are building flows over SharePoint, all the actions will be connected to the development site (unless you use solutions, topic for some post in the future). Moving them to the production site might need an update in all the SharePoint actions. A task that’s quite risky – what if you miss one of the actions? And how annoying it might be to update site and list/library in tens of actions? Is there an easier way to reconnect everything in the flow to a different site?
Start by exporting the flow
You can’t make any mass updates directly using the flow designer, but you can do it directly in the flow code. Start by exporting the flow in a .zip package.
Enter some name for the exported file and export it.
Open the flow definition file
Once downloaded, extract the .zip file and go deep into the folder structure until you get to the definition.json file.
Open it in a code editor (I personally use Visual Studio Code) and you’ll see the original site url and list guid in the code.
This tells the flow where to connect, and that’s the part where you can reconnect the flow. But to get that you’ll need guid of all the lists and libraries on both of the sites. Copy/paste all the guids into a text file.
Now you can start replacing the values in the definition.json files, the old url with the new one, the old guid with the new one.
Replace the file in the .zip file
After you replace all the guids, replace the definition.json file in the .zip file with the new one.
Note: you’ll have to do this in Windows as Mac OS adds an additional folder in .zip files that makes the flow .zip file invalid.
Import the new flow
Import the flow again using the updated .zip file. Go to the flows overview and select Import -> Import Package.
Select the .zip file, pick the connections it should use, and import it.
The imported flow will be connected to the new SharePoint site, lists, and libraries.
Summary
It might be time consuming to reconnect Power Automate flows to a different SharePoint site if you use the designer. Luckily, you don’t have to. You can download the flow as a .zip file, find the connections in the definition.json file and replace them, and import the flow again. Instead of replacing sites/lists/libraries one by one you can replace multiple at once with the editor ‘replace all’ functions. The only challenging part might be to not get lost in all the guids, but if you store them in an organised way you should be fine.
Love your stuff Tom! But this feels like a case of just because we can doesn’t mean we should … Solutions and Environment variables would likely be faster as well, looking forward to that post 🙂