Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Site template JSON schema
Artikel
18-11-2024
The site template is a list of actions. For more complex actions, such as creating a list, there are also subactions. Each action is specified by a "verb" value. Verb actions are run in the order they appear in the JSON script. Only the verb actions listed here can be used; otherwise, an "unable to handle action" error will be thrown when trying to upload a site script. More actions will be added over time.
The overall JSON structure is specified as follows:
{
"$schema": "schema.json",
"actions": [
...
<one or more verb actions>
...
]
}
Actions can be run more than once on a site. Rerunning actions on the same site with the same parameters will result in an update to the existing schema and not duplication of schema.
addContentTypesFromHub
Use the addContentTypesFromHub verb to sync content types from a content type hub to the site.
Notitie
Once addContentTypesFromHub is applied on a site, the addContentType subaction on a list will be able to add it to the list by name.
JSON value
ids: An array of the content type IDs that need to be synced.
Use the createSPList verb to create a new SharePoint list.
Notitie
Once createSPList is applied on a site, running the createSPList with the same list name will act as an update to the existing list.
JSON values
listName: The name of the list.
templateType: Which template to apply to the list. Typically, you would use value 100. The full list of template type values is documented in SPListTemplateType enumeration - but the ones we currently support include:
List Template Name
Enum
Generic List
100
Document Library
101
Survey
102
Links
103
Announcements
104
Contacts
105
Events
106
Tasks
107
Discussion Board
108
PictureLibrary
109
Site Pages
119
Issue Tracking
1100
If you use 101 or 119 and reference the default names ("Documents" or "Site Pages"), you can modify the library created with the template. See example below.
subactions: An array of actions that run in the order listed to create your list.
The subactions array provides additional actions to specify how to construct the list. Subactions are also specified using a verb value.
setDescription
Sets the description of the list.
JSON value
description: The description of the new list.
Example
{
"verb": "setDescription",
"description": "List of Customers and Orders"
}
addSPField
Adds a new field.
JSON values
fieldType: The field type can be set to Text, Note, Number, Boolean, User, or DateTime. For other data types, see the addSPFieldXml action.
displayName: The display name of the field.
id: An optional attribute. If provided, specifies the id of the field. It needs to be a unique, randomly generated GUID. Providing a value for this is recommended to ensure the field isn't added multiple times if the script is rerun.
internalName: An optional attribute. If provided, specifies the internal name of the field. If not provided, the internal name is based on the display name.
isRequired: True if this field is required to contain information; otherwise, False.
addToDefaultView: True if the field will be added to the default view; otherwise, False.
enforceUnique: An optional attribute that defaults to False. If True, all values for this field must be unique.
Enables defining fields and their elements using Collaborative Application Markup Language (CAML). For reference, see Field element (Field). Providing the ID attribute in the field schemaXml is important in order to prevent the field from being created multiple times if the script is run more than once.
Currently these field constructs can't be designated as site columns nor added to content types. To create site columns with Field XML, use the createSiteColumnXml action.
JSON value
schemaXml: The CAML block to define the field.
addToDefaultView: True if the field will be added to the default view; otherwise, False.
Enables defining lookup fields and their dependent lists element using Collaborative Application Markup Language (CAML). For reference, see Field element (Field). Providing the ID attribute in the field schemaXml is important in order to prevent the field from being created multiple times if the script is run more than once.
JSON value
schemaXml: The CAML block to define the field.
targetListName: The name that identifies the list this lookup field is referencing. Provide either this or targetListUrl.
targetListUrl: A web-relative URL that identifies the list this lookup field is referencing. Provide either this or targetListName.
addToDefaultView: True if the field will be added to the default view; otherwise, False.
Defines and adds a view to the list. Use this action to specify the desired columns and how you want the list items displayed (using a CAML query). Action properties allow you to specify row limits, and whether the view is paged and recurses over items in nested folders. You can also designate your constructed view as the default.
JSON value
name: The name of the view.
viewFields: An array of the internal names of the fields in your view.
query: A CAML query string that contains the where clause for the view's query. See CAML schemas.
rowLimit: The row limit of the view.
isPaged: Specifies whether the view is paged.
makeDefault: If True, the view will be made the default for the list; otherwise, False.
scope: An optional setting to specify the scope of the view. For more information, see SPViewScope enumeration.
formatterJSON: An optional setting to specify the JSON formatting for the view.
Removes a view from a list. This action can also be used to remove a view applied by the site template.
JSON value
name: The name of the view to remove.
Example
{
"verb": "removeSPView",
"name": "All Items"
}
addContentType
Adds a content type to the list. Currently these are limited to the default content types included in the site template or ones defined in a script by using the createContentType action.
Notitie
Currently we do not support adding enterprise content types.
JSON value
name: The name of the content type to add.
Example
{
"verb": "addContentType",
"name": "name"
}
removeContentType
Removes a content type that was provided by the selected template type.
Registers field extension for a list field. For more information on these client-side extensions, see Build field customizer tutorial.
JSON values
internalName: The internal name of the field to operate on.
clientSiteComponentId: The identifier (GUID) of the extension in the App Catalog. This property value can be found in the manifest.json file or in the elements.xml file.
clientSiteComponentProperties: An optional parameter, which can be used to provide properties for the field customizer extension instance.
Example
{
"verb": "createSPList",
"listName": "Custom List with Slider Extension",
"templateType": 100,
"subactions": [
{
"verb": "setDescription",
"description": "Custom list to illustrate SharePoint site scripting"
},
{
"verb": "addSPField",
"fieldType": "Text",
"displayName": "Text Field",
"isRequired": false,
"addToDefaultView": true
},
{
"verb": "addSPField",
"fieldType": "Number",
"displayName": "Number Field",
"internalName": "ElectricSlide",
"addToDefaultView": true,
"isRequired": true
},
{
"verb": "associateFieldCustomizer",
"internalName": "ElectricSlide",
"clientSideComponentId": "35944670-3111-4482-b152-9e9d1sean9f7",
"clientSideComponentProperties": "{\"sampleText\":\"Yes - added by a site template, what?\"}"
}
]
}
associateListViewCommandSet
Associates a ListViewCommandSet to the list
JSON values
title: The title of the extension.
location: A required parameter to specify where the command is displayed. Options are: ClientSideExtension.ListViewCommandSet.ContextMenu or ClientSideExtension.ListViewCommandSet.CommandBar.
clientSideComponentId: The identifier (GUID) of the extension in the App Catalog. This property value can be found in the manifest.json file or in the elements.xml file.
clientSideComponentProperties: An optional parameter, which can be used to provide properties for the extension instance.
Renames the list. To create a new list with a specific name, instead of using setTitle use the listName parameter in the CreateSPList action.
Notitie
Using setTitle will rename the list, preventing the list from updating if the site template is reapplied.
JSON value
title: The title of the new list.
Example
{
"verb": "setTitle",
"title": "Customers and Orders"
}
Define a new site column
Use the createSiteColumn verb to define a new site column that can then be associated to a list directly or by using the addContentType action.
JSON value
fieldType: The type of column to add. Supported values - like SPField - are Text, Note, Number, Boolean, User, and DateTime. For other data types, refer to the addSPFieldXml script action.
internalName: The internal name of the site column.
displayName: The display name of the site column.
isRequired: True if this field is required to contain information; otherwise, False.
id: An optional attribute. If provided, specifies the id of the field. It needs to be a unique, randomly generated GUID. Providing a value for this is recommended to ensure the field isn't added multiple times if the script is rerun.
group: An optional attribute to designate the column group.
enforceUnique: An optional attribute that defaults to False. If True, all values for this field must be unique.
Use the createSiteColumnXml verb to define a new site column for those complex data types not supported by createSiteColumn. These columns can then be associated to a list directly or by using the addContentType action. Providing the ID attribute in the field schemaXml is important in order to prevent the field from being created multiple times if the script is run more than once.
JSON value
schemaXml: The CAML block to define the field.
pushChanges: Indicates whether this change should be pushed to lists that already reference this field. Defaults to True.
Use the addNavLink verb to add a new navigation link to the site QuickLaunch or Hub navigation.
JSON values
url: The URL of the link to add.
displayName: The display name of the link.
navComponent: The component where to add the link, QuickLaunch, Hub, or Footer. The default is QuickLaunch.
isWebRelative: True if the link is web relative; otherwise, False. The default is False.
parentDisplayName: An optional parameter. If provided, it makes this navigation link a child (sub link) of the navigation link with this displayName. If both this and parentUrl are provided, it searches for a link that matches both to be the parent.
parentUrl: An optional parameter. If provided, it makes this navigation link a child (sub link) of the navigation link with this URL. If both this and parentDisplayName are provided, it searches for a link that matches both to be the parent.
isParentUrlWebRelative: An optional parameter. True if the link is web relative; otherwise, False. The default value is False.
Example
Notitie
If you add a link to a nested site item such as a list, be sure to add the path reference from the root.
Use the removeNavLink verb to remove a navigation link from the site.
JSON values
url: The URL of the link to remove.
displayName: The display name of the link.
navComponent: The component where to remove the link from, QuickLaunch, Hub, or Footer. The default is QuickLaunch.
isWebRelative: True if the link is web relative; otherwise, False.
Example
Notitie
This action can be used to remove site links added by the collaboration and communication site templates (for example, "home", "documents", "pages", and "conversations").
The sites created in other languages than English may contain special characters. Use UTF-8 encoding to read the JSON content containing special characters.
Use the applyTheme verb to add a custom theme to the site. For more information about how to construct and upload these themes, see SharePoint site theming. This site action only works for applying custom themes; to apply one of our in-product SharePoint themes, create a copy as a custom one and reference that one.
Notitie
This action is automatically blocked for channel sites.
Use the setSiteBranding verb to specify the navigation layout, the header layout, and header background.
Notitie
Setting the navigation layout only works on the communication site template and for the hub navigation.
This action is automatically blocked for channel sites.
JSON value
navigationLayout: Specify the navigation layout as Cascade or Megamenu
headerLayout: Specify the header layout as Standard or Compact
headerBackground: Specify the header background as None, Neutral, Soft, or Strong
showFooter: Specify whether site footer should show or not
Use the installSolution action to install a deployed add-in or SharePoint Framework solution from the tenant App Catalog.
Example
Notitie
To get the solution ID, sign in to a site by using the Connect-PnPOnline cmdlet, and then run Get-PnPApp. This returns a list of your deployed solutions. For multi-geo tenants, use the Product ID after setting up the solution in each geo location. Obtain the Product ID by uplaoding the solution to the app catalog or in the solution's definition.
title: The title of the extension in the App Catalog.
location: Used to specify the extension type. If it's used to create commands, then where the command would be displayed; otherwise this should be set to ClientSideExtension.ApplicationCustomizer.
clientSideComponentId: The identifier (GUID) of the extension in the App Catalog. This property value can be found in the manifest.json file or in the elements.xml file.
clientSideComponentProperties: An optional parameter, which can be used to provide properties for the extension instance.
registrationId: An optional parameter, which indicates the type of the list the extension is associated to (if it's a list extension).
registrationType: An optional parameter, which should be specified if the extension is associated with a list.
scope: Indicates whether the extension is associated with a Web or a Site.
This action is automatically blocked for channel sites.
Use the addPrincipalToSPGroup action to manage addition of users and groups to select default SharePoint groups. For more information, see Understanding SharePoint Groups. This action can be used for licensed users, security groups, and Microsoft 365 groups.
JSON values
principal: A required parameter to specify the name of the principal (user or group) to add to the SharePoint group.
group: A required parameter to specify the SharePoint group to add the principal to.
Example
Notitie
This action currently only supports the Visitors (permission level: read), Members (permission level: contribute or edit, depending on the site template), and Owners (permission level: full control) groups. Principals must be added individually.
capability: A required parameter to specify the sharing option for the site collection. The four options are: Disabled, ExistingExternalUserSharingOnly, ExternalUserSharingOnly, and ExternalUserAndGuestSharing.
This module provides instruction on how to create groups for distributing email to multiple users within Exchange Online. It also explains how to create groups to support collaboration in SharePoint Online.