A cloud-based solution, Microsoft® (MS) Flow effectively automates and simplifies business processes by creating automated workflows with MS Flow.
This post describes how to create a fully automated bulk solution to provision a sub-site in SharePoint® Office 365® (SPO) for any site creation requests that come through a custom list. You can achieve this goal by using a scheduled MS Flow workflow and the REST API features.
When you create a workflow, keep the following considerations in mind:
Create new requests in a custom list.
The approval workflow might not run on the newly created item.
A scheduled MS Flow (Power Automate) workflow picks up all the approved requests from the list and provisions a site. The scheduling time depends on your requirements.
After you provision the site, you should update the value in a custom list so that the system won’t pick up the request when the next workflow runs.
Steps to build the solution:
Create a custom list
Create and schedule a workflow
Create a custom SharePoint list, Site Creation Request, with the first eight columns in Figure 1.
Figure 1 : Set of columns
Now add items to the Site Creation Request list.
For example, add two items to the list, one without a unique permission and another with a unique permission, as shown in Figure 2.
The IsUniquePermission column indicates if the requested site inherits permissions from its parent or is a unique permission.
The Site Template column contains the Site Template ID in the following format:
Figure 2 : Add an item to site creation request list
Use the following steps to create and schedule an MS Flow workflow:
Build a scheduled flow, as shown in Figure 3, pass all the parameters, and click Create.
Figure 3: Create the scheduled workflow
In the next screen, after the recurrence step, add two Initialize Variable actions for the List Name and IsUniquePermission variables, as shown in Figure 4.
Figure 4: Add the initialize variable action
Add a Get Items action to fetch all the records from the Site Creation list based on the condition, Approved is equal to Yes and Site Created is equal to No, as shown in Figure 5.
Note: The Filter Query parameter receives only OData Query.
Figure 5: Add the get items action
Add the Apply to each action and select the value from the previous Get Items action, as shown in Figure 6.
Figure 6: Add the Apply to each action
Inside the Apply to each block, add a Compose action to get the Site Template ID of the current item in the loop. Split the selected Site Templated Id and get only the Site ID from the value, by using the following command, as shown in Figure 7.
Figure 7: Add the Apply to each action
Inside the Apply to each block, add a Send an HTTP request to SharePoint action to construct and execute a SharePoint REST API call to provision a site based on the parameters, as shown in Figure 8.
The details of the map request follow:
The body parameter details include the following elements:
Title: Maps to the column SubSite.
WebTemplate: Gets the output from the Site Template ID action by using
UseUniquePermissions: Maps to the column IsUniquePermission.
Figure 8: Add the HTTP request to provision the site
Add a Send an HTTP request to SharePoint to update the Site Created
column of the current item to
YES, as shown in Figure 9.
The details of the map request follow:
Note: The highlighted value in Figure 9 is the static name of the Site Creation list.
Figure 9: Add the HTTP request to update an item
Complete the Apply to each action, as shown in Figure 10.
Figure 10: Apply to each block
Complete the scheduled workflow, as shown in Figure 11.
Figure 11: Complete the workflow for site creation
I hope this post helps you understand how MS Flow and the REST API work together with SharePoint sites and list-based operations. One of the most significant advantages of Flow is that it is incredibly easy to use, and even people with no technical background can create workflows without trouble.
Use the Feedback tab to make any comments or ask questions. You can also chat now to start the conversation.