Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue...

Post on 08-Aug-2020

2 views 0 download

Transcript of Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue...

Todd Klindt

• 14 Year SharePoint MVP

• Writer, speaker, podcaster, consultant at Sympraxis Consulting, SysKit Chief Evangelist

todd.klindt@sympraxisconsulting.com

@toddklindt

www.toddklindt.com

www.toddklindt.com/SPSNashville

Session Overview

The Bad and the Ugly

• Only worked for Classic Team sites – “cheating” on Publishing sites often

broke

• So flaky they removed it from SharePoint Online

• No way to update sites once they are created

• Brittle – content sometimes breaks (error when clicking on a list for

example)

• Difficult to debug; generally arcane

The Good

• Easy peasy – make a sample of what you want, save as a template, then

use the template to create new site(s)

It takes work to be this beautiful!

See: Idempotent Site Scripts for SharePoint

Using Site Scripts to Deploy Content Types

See: SharePoint site design and site script overview and Site design JSON schema: Define a new content type

Site designs: modern templating model

A new script model to apply custom “actions” to a site after creation.

This approach is inspired by the “remote provisioning” pattern we’ve espoused through PnP

• Updating existing sites with common site elements

• Configuring sites associated to a hub

Site Instances

Site Instances

Site Instances

Site Instances

Available Site Script Actions

JSON Schema: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-json-schema

Site Settings

• addPrincipalToSPGroup

• addNavLink

• removeNavLink

• applyTheme

• setSiteLogo

• setSiteBranding

• setRegionalSettings

• setSiteExternalSharingCapability

• triggerFlow

• joinHubSite

• activateSPFeature

SharePoint Components Apps & Solutions

• createSPList

• addSPField

• deleteSPField

• addSPFieldXml

• createSiteColumn

• createSiteColumnXml

• addSiteColumn

• addContentType

• createContentType

• removeContentType

• addSPView

• removeSPView

• setSPFieldCustomFormatter

• installSolution

• SPFx Extension support• associateExtension

• associateListViewCommandSet

• associateFieldCustomizer

"$schema": "schema.json",actions: [...{

"verb": "createSPList","listName": "Contoso Project Tracker","templateType": 100,"subactions": [

{"verb": "SetDescription","description": "Custom list to illustrate

SharePoint site scripting capabilities"},{

"verb": "addContentType","name": "Contoso Projects"

},{

"verb": "addSPFieldXml","schemaXml": "<Field Type=\"Choice\"

DisplayName=\"Project Status\" Required=\"FALSE\" Format=\"Dropdown\" StaticName=\"ProjectStatus\" Name=\"ProjectStatus\"><Default>In progress</Default><CHOICES><CHOICE>In progress</CHOICE><CHOICE>In review</CHOICE><CHOICE>Has issues</CHOICE><CHOICE>Done</CHOICE></CHOICES></Field>"

},{

"verb": "addSPView","name": "Contoso Projects by Status","viewFields":

...

Site Script: JSON file of

actions to be applied to the

site post-creation

Actions can be concatenated in

single file or multiple files can be

used (and reused)

Add-SPOSiteDesign-Title <string>-WebTemplate <string>-SiteScripts <SPOSiteScriptPipeBind[]>[-Description <string>][-PreviewImageUrl <string>][-PreviewImageAltText <string>][-IsDefault]

Site Design attributes

designate display

characteristics and target

template

LIMITS• 100 site scripts and site designs

per tenant

• 30 actions/design if applied sync

(Invoke-SPOSiteDesign)

300 actions if applied async

(UI or Add-SPOSiteDesignTask)

• 30K characters/design

Get-SPOSiteScriptFromWeb –WebUrl $siteUrl-IncludeTheming –IncludeBranding-IncludeSiteExternalSharingCapability–IncludeRegionalSettings–IncludeLists $relativeListUrls

Tips and Tricks – Github Samples

Tips and Tricks – Create a Theme per Site Design

Add-SPOSiteScript -Title $siteScriptTitle –Content $siteScriptJson

Add-SPOSiteDesign -SiteScripts [$siteScript.Id]-Title $siteDesignTitle -WebTemplate $webTemplate-Description $siteDesignDescription-PreviewImageUrl $previewImageUrl-DesignPackageId $designPackageId

Grant-SPOSiteDesignRights -Identity $siteDesign.Id-Principals ("user@tenant.onmicrosoft.com")-Rights View

Set-SPOHubSite $hubSiteUrl -SiteDesignId $siteDesign.Id

Invoke-SPOSiteDesign -Identity $siteDesign.Id-WebUrl "https://contoso.sharepoint.com/sites/projectawesome"

Add-SPOSiteDesignTask -SiteDesignId $siteDesign.Id-WebUrl "https://contoso.sharepoint.com/sites/projectawesome"

Site Design PowerShell

var flowScript = {"$schema": "schema.json","actions": [{

"primary_verb": "Flow.Trigger","target": “<<http post url>>","name": “contoso hr additions","parameters": {

"department": "HR","cost center": "1023"

}}

],"bindata": {},"version": 1

};

Site Scripts with app integrationHow to integrate custom logic into out-of-box provisioning flow

SharePoint

Online

Storage

Queue

Azure Function

Microsoft Flow

Site URL is used as a parameter to connect to site

using remote APIs. Customizations applied using

remote provisioning techniques, for example with

PnP remote provisioning template model.

Script initiates previously configured flow, using

the newly created site URL as parameter. Flow

includes a step to pass site URL to Azure storage

queue for delegating processing to Azure side.

1 2

3

4

triggerFlow script action

• Site URL

• Site Description

• Created By

• Creator Email

• UTC Creation Time

Site Designs for Existing Sites!

PowerShell or REST can be used to apply a published design to a site.

Notes

http://bit.ly/UltimateGuide2SiteDesigns

http://bit.ly/SiteDesignOverview

http://bit.ly/SiteDesignSchema

http://bit.ly/SwoopingSiteDesigns

http://bit.ly/SwoopingSampleCode

http://bit.ly/SiteDesignAttachHubs

http://bit.ly/OfficeThemeGen

todd.klindt@sympraxisconsulting.com

@toddklindt

www.toddklindt.com

www.toddklindt.com/SPSNashville

Session Feedbackbit.ly/O365N-Todd

• Anonymous

• Results go to Speaker

• Greatly Appreciated