XM Cloud Datasource Workflows: What, Why, and How

What is a Workflow in Sitecore?

In Sitecore, a workflow defines the series of steps content must go through before it can be published. It ensures that all content is reviewed and approved before becoming visible to website visitors. A typical workflow includes stages like Draft, In Review, and Approved to keep track of progress and prevent accidental publishing of unfinished content.

Most workflows in Sitecore are applied to pages and components. However, a datasource workflow is a little different. It applies to content stored separately in folders, not full pages. A datasource workflow ensures that this reusable content is properly reviewed and approved before being displayed in multiple places on the website.

Why Use a Datasource Workflow?

Using workflows for datasource items provides several advantages:

  • Control: Ensures that datasource items follow the same review process as full pages.
  • Reusability: Since datasource items are often reused across multiple pages, workflows prevent unapproved changes from affecting multiple locations.
  • Collaboration: Allows multiple content editors to contribute while maintaining oversight.
  • Versioning and Rollback: Keeps track of changes and allows reverting to previous versions if needed.

How to Implement a Datasource Workflow in Sitecore

Let’s look at a scenario where you have both a Page Workflow and a Datasource Workflow. In this setup, approving a page also automatically approves all datasource items associated with that page.

1. Create your Page Workflow. Setup the workflow and the states. Draft, Awaiting approval, Approved for instance. Add the necessary commands, such as Submit under the Draft state.


2. Create your Datasource workflow.

In your datasource workflow, create a command in the Draft state called Submit and Approve, and set the Next state to Approved.

This setup allows datasource items to be automatically approved when the page they’re linked to is approved.


3. Add Datasource Workflow Actions

Add a Datasource Workflow Action and point it to the command you created in Step 2 (Submit and Approve).

Here’s how the flow works:

  • The page (in Draft) is submitted.
  • The Datasource Workflow Action triggers the Submit and Approve command on all linked datasource items.
  • Because this command moves datasource items to Approved, they are automatically published along with the page.

If you prefer manual approval for datasources, you can instead move them to an Awaiting Approval state rather than approving automatically.


Now you can test and verify your workflows in Pages.
Workflows are very flexible, you can change these actions to match your specific needs. Try it out and get familiar with it.

Custom Roles Setup in Sitecore XM Cloud

Overview

If you have multiple sites under a Site Collection and want to manage access per site or across the entire collection, it’s best to create custom roles. This gives you flexibility, for example, some editors can be Authors for the whole Site Collection, while others only have access to a specific Site.

If you only have one site or don’t need granular access, you can use the default Site Collection roles and Site roles in Sitecore. In that case, simply run the Setup Security script on your Site Collection and then on the Site.

Recommended Role Structure

Create custom roles before running Setup Security.
Preferably create 4 roles per Site Collection and 4 per Site. Use the Sitecore domain.

Site Collection Roles:
sitecore/MySiteCollection Admin
sitecore/MySiteCollection Author
sitecore/MySiteCollection Designer
sitecore/MySiteCollection Member

Site Roles:
sitecore/MySite Admin
sitecore/MySite Admin
sitecore/MySite Admin
sitecore/MySite Admin

Create your new custom roles for a new Site by creating 4 new roles.
Create new roles in the Sitecore domain. Follow this pattern:

For the headless Site Collection, you create 4 new roles for that Site Collection aswell.

Role Membership Setup

In Role Manager, select the <Site> Author role, then click Member Of. Make it a member of:

  • sitecore\<Site> Member (itself)
  • sitecore\<SiteCollection> Member

You can add additional Sitecore roles (e.g., Sitecore Client Securing) if needed.
Read more about Sitecore roles

Running the Setup Security Script

  1. In Content Editor, right-click your Site Collection and run Scripts > Setup Security.

2. Choose sitecore as domain

3. In the dialog, link the 4 custom roles to the appropriate fields before clicking Assign.

4. Then repeat for the Site.

You can now assign users to your new Author role and they should be ready for editing your site. Don’t forget to setup Workflows to make the editor experience as expected in Page builder!

Notes

If you only have 1 site or don’t see a reason to split the roles up in any way, there are default Site Collection roles and Site roles predefined in Sitecore that you could use instead and just run the Setup Security script on your Site Collection and Site. But for granular access rights I recommend setting up site specific roles.