“With the old SharePoint I was able to create a template from a list and move it to another environment, how can I do that with SP Online, can Power Automate help?”
If you’ve got multiple SharePoint environments, e.g. development and production one, you’ll encounter a situation when you must move a solution. And one piece to move might be related SharePoint lists. While it was easy in the past to move lists (you could export list including all content), SharePoint online doesn’t have this feature. You can create copies only from lists which are already on the environment, but what about other environments? How can you move a list from your development environment to production?
Export the list
The approach is very similar to creating a new list from existing ones, but this time it’s not a single flow. You’ll need at least two – one flow to extract the list from the current environment, and one to import it in the new environment.
The extracting flow will be simple, just two actions – manual trigger and ‘Send an HTTP request to SharePoint’.
Method: POST
Uri: _api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.GetSiteScriptFromList()
Headers:
{
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
}
Body:
{
"listUrl": "<full list url>"
}
Run the flow and open the flow run history. The output of the HTTP request is the list structure – store it somewhere, e.g. in a text file or in an email.
Import the list
Once you have the list structure, you can use it to create the list on another environment. Start with a manual trigger and a ‘Compose’ action, and copy the output from the HTTP request in there.
Add ‘Parse JSON’ to remove all the special characters from the schema. Navigate in the JSON to get only the content form the GetSiteScriptFromList and parse it. Use the whole content of the ‘Compose’ action as the sample schema.
outputs('Compose')?['d']?['GetSiteScriptFromList']
Finish the flow by the ‘Send an HTTP request to SharePoint’ action to use the schema to create the list.
Method: POST
Uri:
_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.ExecuteTemplateScript()
Headers:
{
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
}
IMPORTANT NOTE: it seems there was a change in the requests, now you must include also information whether the list should be added to the navigation (true/false) and rename the list to a nicer name.
{"script": "{\"actions\":[@{replace(replace(string(setProperty(setProperty(body('Parse_JSON')?['actions'][0],'listName','NewListName'),'addNavLink',true)),'\','\\'),'"','\"')}]}"}
Run the flow and it’ll create the list on the SharePoint site in another environment.
Summary
Even though Microsoft removed the functionality to easily move SharePoint list between environments, you can build similar functionality using Power Automate. One flow to export the list on the source environment, another flow to import in on the target environment, and the list definition to be manually moved between the two flows.
Like you mentioned, this is like creating a list from an existing list. What I am looking for is moving a list to a new site, meaning that all of the data in the list goes with it. This was available in SharePoint Designer, but i am having trouble doing it now with power automate and O365
Hello jr,
you’ll need another flow to do that, a flow that’ll list all items in the original list and recreate them in the new one.
What would be your recommendation when deploying an incremental update and we must synchronize schema changes between lists in 2 SharePoint site?