create-component-datasource
Creates a Sitecore datasource item for a component, using the rendering's Datasource Template and Location. Supports page-local or shared placement and sets provided field values.
Instructions
Creates the datasource item for a component, using the Datasource Template and Datasource Location declared on the rendering itself. placement='page-local' (default) creates /Data/ and returns the layout reference form 'local:/Data/' that authored pages use; placement='shared' resolves the rendering's pipe-separated Datasource Location candidates in order and creates the item in the first that exists, returning the item ID to reference it by. Fails naming every candidate it tried when none resolves, rather than guessing at a location. Pass the field values in 'fields' and they are set on the new item.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Name for the new item. Defaults to '<RenderingName> <n>' with the lowest free n, which is the convention the authored pages use (e.g. 'RichText 1'). | |
| path | No | The full path of the item, database prefix optional (e.g. master:/sitecore/content/Stride/Cova/Home or /sitecore/content/Stride/Cova/Home). Supply this or pageId. | |
| fields | No | Field values to set on the new item, keyed by Sitecore field name. | |
| pageId | No | The ID of the page item (e.g. {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}). Supply this or path. | |
| database | No | The database to read. Defaults to master, and is ignored when path carries its own prefix. | |
| language | No | The item language. Defaults to the context language. | |
| placement | No | Where to create the datasource. 'page-local' (default) puts it under <page>/Data, referenced from the layout as local:/Data/<name>, so it lives and dies with the page. 'shared' puts it in the site Data folder that the rendering's Datasource Location resolves to, for content reused across pages. | |
| renderingId | No | ID of the rendering definition item (e.g. {AD10DB7C-C944-42D9-9563-1F1070CC922E}). Supply this or renderingPath. | |
| renderingPath | No | Path of the rendering definition item (e.g. /sitecore/layout/Renderings/Project/Stride/RichText). Supply this or renderingId. |