Monday, 22 January 2018

SharePoint Online: Combine and reuse multiple site scripts in a site design

Site scripts and site designs were recently introduced in SharePoint Online/Office 365. They provide a great way to hook into the out of the box site creation dialog to apply customisation to the site being created. Here are some great articles if you want an overview of site scripts and site designs:



In the most basic sense, 

Site scripts are the JSON files used to define the artefacts to be created or the customisation to be applied after the site is created.

Site designs are site templates created by combining one or more site scripts. They can be assigned a title, description, preview image etc. which will be presented to the user in the 'Create new site' dialog.

In this post, let's have a look at how we can combine and re-use multiple site scripts to create site designs.

Here, I have a site script to create a document library on site creation:


Next, I have another site script to trigger a Microsoft Flow on site creation:


Now, here is a PowerShell script which will create 2 different Site Designs (templates). 

The first site design will only be configured to have the site script to create the document library.

The second site design will contain the same site script to create the document library. But in addition, it will also contain the site script to trigger a Microsoft Flow.


Once both site designs are successfully created, they will appear in the "Create a site" dialog on the SharePoint home in Office 365:



This way, you can combine and re-use multiple site scripts to create different site designs as per business requirements.

Troubleshooting:


1) Site scripts and site designs are in preview now and not meant to be used in production. They are also being gradually rolled out to Targeted Release tenants. I was only able to test them in 1 of my tenants. In all other tenants, I was getting the message: "The requested operation is part of an experimental feature that is not supported in the current environment."

2) You will need the latest version of the SharePoint Online Management Shell to get the site design cmdlets: https://www.microsoft.com/en-us/download/details.aspx?id=35588

4 comments:

Dhaval Raval said...

Would this work for classic UI/Experience in sharepoint online ? Can you run powershell being only site collection administrator ?

Vardhaman Deshpande said...

Hi Dhaval,

This only works with the Modern Experience and that too with modern team (O365 group connected) sites and communication sites.

I believe you have to be a tenant admin to manage Site Designs through PowerShell.

Vikas dhingra said...

As you have added new templates, is there any way to hide the communication sites from the create sites? I just want to give Team site option to users.

Vardhaman Deshpande said...

Hi Vikas, at this time I don't think there is an option to hide the communication site and keep the team site only.