Using Your Own State Flow for CMP Content Items Instead of the Default

Hello Sitecorians! 👋


Every CMP content item in Sitecore Content Hub moves through a review process: To do, In progress, In review, Ready to publish. That process is a state flow, and out of the box every content type uses the same default one.


But real teams rarely review a blog the same way they review a social post or an email. In this blog, I will show how to create your own state flow for one content type (we will use Blog), start it automatically, and keep the default flow for everything else.


So, let's get started! 😊


What Is a State Flow?

A state flow (also called a state machine) is a set of states and the transitions between them, defined for one entity definition. For CMP, that definition is M.Content.


Each state can:

  • Assign the item to user groups (who should act now).
  • Update the content status (for example In progress or Final).
  • Send an email to the assignees, using an email template.


The default CMP flow

Out of the box, CMP content follows this flow:


From

To

When

To do

In progress

Start

In progress

In review

Send for review

In review

In progress

Rejected

In review

Ready to publish

Approved

Ready to publish

Archived

Archived

Ready to publish

In progress

Reset for rework

Archived

Ready to publish

Unarchived


How a flow gets started

This is the part that is easy to miss. A content type is not linked to a state flow by a field. The flow is started by a trigger:

  1. A content item is created or changed.
  2. A trigger (CMP - Content approval trigger for the default flow) checks its conditions, for example Approved for creation is on.
  3. If they match, the trigger runs an action of type Start state machine, which starts the flow on that item.


So to use your own flow for one content type, you need three things: your state flow, an action that starts it, and a trigger that runs that action only for your content type. And you must tell the default trigger to skip that type, so the two flows don't both start.




Blog items go to the new Blog flow; every other content type keeps using the default CMP flow.


The Use Case

Say the business wants a simpler, stricter review for blogs:

  • Create: the author writes the blog.
  • Review: the Editors group reviews it.
  • Approved: the content is final and ready to publish.


Each step should assign the item to the right group and notify them by email. Social posts, emails and every other content type should keep the default CMP flow, untouched.


This pattern works for any content type and any number of steps, for example an extra Legal review for press releases, or a Brand review for campaigns. The steps below use the Blog example, but you can follow the same recipe for your own case.


Note: To do this, you need to be a superuser, or have the permissions to manage state flows, actions and triggers through user group policies. Do it on a lower environment first.


Step 1: Create the State Flow and Its States

Create the state flow

  1. Go to Manage → State flows and click + State flow.
  2. Fill in the dialog:
    • Target definition: M.Content (this is what makes it a CMP flow).
    • Name: Blog flow. Users see this name, so make it clear.
    • Detail page: optional. It adds a link to a page in the notification email.
    • Email template: click Add, select CMP, and click OK.
  3. Click Save.

The State flows page, with the default CMP flow and the + State flow button:



The State flow dialog:



Add the states

Open Blog flow and click State to add each state. Every state has a set of "update" options. Overwrite sets a new value when the item enters the state, and Keep leaves the current value as it is.


State

Assigned user groups

Content status

Purpose

Create

M.Builtin.Creator

Overwrite → In progress

The author writes the blog.

Review

M.Builtin.Editors

Keep

Editors review the blog.

Approved

Superuser (or your publishers group)

Overwrite → Final

Approved and ready to publish.


For each state:

  • Give it a short Description, for example Blog content is being reviewed by the Editors.
  • Set Update assignees to Overwrite and pick the user group from the table.
  • Set Update status as shown in the table.
  • Leave Update state flow, Update draft status, Update approved for creation and Update is in ideation state on Keep.

Tip: Use your own user groups instead of the built-in ones in a real project, for example Blog Authors and Blog Editors. Then you control exactly who gets assigned and notified. If the reviewer changes per item (for example per brand or region), look at dynamic user groups.


Step 2: Add the Transitions and the Start Action


Add the transitions

Transitions are the buttons users click to move the item on. On the Blog flow page:


  1. Next to Create, click Edit transitions and add a transition named Send for review, with Review as the next state.
  2. Next to Review, add a transition named Approve, with Approved as the next state.
  3. Optionally, on Review, add Reject with Create as the next state, so editors can send the blog back to the author.

Tip: Name the transitions as actions (Send for review, Approve, Reject). That is the label users see on the button, so a verb is much clearer than a state name.


Make sure the state flow is enabled. A disabled flow cannot be started.


Create the Start state machine action

A trigger cannot start a flow directly. It runs an action, and the action starts the flow.

  1. Go to Manage → Actions and click New action.
  2. Fill in:
    • Name: Blog content approval action
    • Action label: Blog approval action
    • Type: Start state machine
    • State flow: Blog flow

  3. Click Save.


Step 3: Link the Flow to the Blog Content Type with a Trigger


This is the step that makes Blog items use your flow.

  1. Go to Manage → Triggers and click New trigger.
  2. On the General tab:
    • Name: Blog content approval trigger
    • Description: Starts the Blog flow for blog content
    • Objective: Entity creation and Entity modification
    • Execution type: In process
  3. On the Conditions tab, click Add definition and select Content (M.Content). Then add two conditions, joined with and:



Field

Value

Operator

Match

Approved for creation (Content.ApprovedForCreation)

Current value

equals

On

Type (ContentTypeToContent)

Current value

contains (all)

Blog


  1. On the Actions tab, under Post actions, click Add action and select Blog content approval action.
  2. Click Save, then Activate.


Why these two conditions? Content.ApprovedForCreation becomes true when the idea is approved and the item moves from ideation into CMP. That is exactly the moment the default flow starts too. ContentTypeToContent is the relation we saw in the last part, which links the item to its content type. Together they say: start the Blog flow when a Blog item is approved for creation.


Step 4: Exclude Blogs from the Default Trigger


If you stop here, a Blog item matches both triggers, and both flows try to start. So tell the default trigger to skip blogs:


  1. Go to Manage → Triggers and open CMP - Content approval trigger (View details).
  2. On the Conditions tab, click Condition and add:
    • Type (ContentTypeToContent), Current value, does not contain, all, Blog.
  3. Click Save and close.


Important: Only add a condition to the default trigger. Don't change or remove its existing conditions or actions, or the other content types lose their flow. And note the change somewhere for your team, because it is easy to forget that the default trigger was touched.


Testing: 

With one state flow, one action and two trigger changes:

  • Blog items now follow Create → Review → Approved, assigned to the right groups, with email notifications.
  • All other content types keep the default CMP flow, exactly as before.
  • Nothing was coded. Everything is configuration, so it is easy to change, export and promote.

Let's test it. Create a new content item with Type set to Blog:



The item starts in the Create state of our flow (not To do), and the header shows the Send for review button:



After Send for review, the item is in Review, and the button changes to Approve:



Click Approve, and the item reaches Approved with the message State is applied successfully:



Sources


Conclusion

The default CMP flow is a good start, but it is one size for all. A custom state flow lets each content type follow the review process the business really uses. The key thing to remember is that a content type is linked to a flow by a trigger, not by a setting: create your flow, start it with a Start state machine action from a trigger filtered on your content type, and exclude that type from CMP - Content approval trigger. Test it on a lower environment, and move all the pieces together.


I hope this helps you in your Content Hub journey! If you have any questions, feel free to drop a comment below. 😊


Stay tuned for more! 👋

Post a Comment (0)
Previous Post Next Post