Share via


SharePoint: Create Site Using SP Designer Workflow

Some of us want to create a SharePoint site when an item is added to a SharePoint list. For SharePoint on-premise, we can achieve this using the event receivers and with SP online we can use designer workflow with REST API call to achieve this.

Introduction to Designer Workflows

  • SharePoint Designer is one of the best tools to create the workflows.
  • A lot of activities, actions, and conditions are available in Designer. We can create rules that associate conditions and actions with items in SharePoint List and Libraries.
  • We can use the workflow for the business process and approval process.

Below is the workflow start options for SharePoint List & Libraries:

  • Allow workflow to be manually started.
  • Start workflow automatically when an item is created.
  • Start workflow automatically when an item is changed.

Steps to Create a site using Workflow

In a previous article we have seen how to create list workflow using SP designer.

Once you have created the list workflow using the above article follow the below-listed steps to create a site using designer workflow.

Note

You need to activate the “Workflow can enable app permission” feature to enable the app step in the designer. Inside the app step only we will add the logic (REST API call) to create a site. The user performs the below step to activate the feature.

Go to site - settings - Manage site features - “Workflow can enable app permission” - Activate

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image001.jpg

After activating the feature get the app identifier.

Go to site - settings - App permissions

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image002.jpg

On the site app permission page, you can see the workflow then get the workflow id as shown below.

App Permissions

Then go to the appinv.aspx page using below URL,

Append /_layouts/15/appinv.aspx to site URL to see the hidden App Permissions page

  • Enter the selected workflow App ID and click pop up

Provide below XML on the Permission Request XML Textbox as shown below and click on Create button.

  1. <AppPermissionRequests>  
  2.    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl"/>  
  3. </AppPermissionRequests>  

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image003.jpg

App Step will be enabled on the designer after you do the above steps. Then follow the below procedure.

Step 1 Variables in workflow

Create variables in workflow,

  • Title - New Site Title
  • Description - New Site Description
  • SiteURL - New site URL name
  • SiteTemplate - it may be team site, blog, project etc.
  • RequestURL - URL of Where the site has to be created

Here is the Workflow screenshot for your reference

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image004.png

Step 2: Dictionary

Build a dictionary value for REST API call, below dictionary values need to be created.

RequestHeaders

Name  Type  Type 
Accept String application/json;odata=verbose
Content-Type String application/json;odata=verbose

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image005.png

MetaData

Name  Type  Type 
Type String SP.WebInfoCreation

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image006.png

Parameters

Name Type Value
__metadata Dictionary Variable: MetaData
Url String Variable: SiteURL
Title String Variable: Title
Description String Variable: Description
Language Number 1033
WebTemplate String Variable: SiteTemplate
UseUniquePermissions Boolean False

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image007.jpg

RequestDictionary

Name Type Value
parameters Dictionary Variable: Parameters

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image008.jpg

Step 3 Add app

Once the variables have been created add the app step to the workflow as shown below,

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image009.png

Step 4: HTTP call

Then add the HTTP call activity inside the app step,

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image010.jpg

Step 5: Advance properties

Then right-click on the activity and click the advanced properties from the top ribbon,

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image011.jpg

Step 6: Responsive content

Set the properties & create a new variable for responsive content.

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image012.png

Step 7 Save

Then save the workflow and check for errors,

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image013.png

Step 8 Publish

Finally, publish the Workflow.

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/create-sharepoint-site-using-sp-designer-workflow/Images/image014.jpg

When you create an item in the list the site will be created successfully.