Selecting a workflow using content labels

Overview

This is a way for workflow authors to control the workflows users can apply to their content.

The example uses three active workflows in a space

  • a Workflow Selector workflow that is applied to content in a space by default
  • two workflows each with a label filter

This makes it easier for users to select the workflow to apply to a page without giving users the ability to customize the workflow.

Workflow Selector workflow

The workflow applied by default to new content has an initial state that allows a user to select one of two workflows by choosing an appropriate state.


There are two triggers each listening for a statechanged event.


  • the first trigger listens for the state change to the Project One state
  • the second trigger listens for the state change to the Project Two state

Each trigger

  • adds a label to the content that is used to filter the workflow applied to the page
  • sets a state in the content filter workflow

The addition of the label causes the application of the appropriate label filter workflow.

{workflow:name=Workflow Selector}
    {state:Select State for Workflow}
    {state}
    {state:Project One}
    {state}
    {state:Project Two}
    {state}
    {trigger:statechanged|state=Project One}
        {set-label:projectone}
        {set-state:Draft Project One}
    {trigger}
    {trigger:statechanged|state=Project Two}
        {set-label:projecttwo}
        {set-state:Draft Project Two}
    {trigger}   
{workflow}


Project One workflow

The second workflow, Project One has a content filter projectone. This workflow adds the label as a stickylabels. Adding stickylabels=true  prevents labels from being removed except by a user with admin permission.

{workflow:name=Project One Workflow|label=projectone|stickylabels=projectone}
    {state:Draft Project One}
    {state}
    {state:Cheese}
    {state}
    {state:Bacon}
    {state}
{workflow}

Project Two workflow

The third workflow, Project Two has a content filter projecttwo. This workflow also adds the label as a stickylabels.

{workflow:name=Project Two Workflow|label=projecttwo|stickylabels=projecttwo}
    {state:Draft Project Two}
    {state}
    {state:Jam}
    {state}
    {state:Donut}
    {state}
{workflow}

How it works

When you create a new page the Workflow Selector workflow is enabled and applied to the content.


Select a destination state in the workflow popup.

Choosing the Project One state will initiate the following trigger actions

  • setting the content label as projectone
  • set the state to the Draft Project One state

The addition of the projectone  label to the page will apply the Project One workflow.

Choosing the Project Two state will cause the addition of the projecttwo label.

The state is set to the Draft Project Two and the Project Two workflow is applied.


Note that the initial states set in each content filter workflows can use the same name. States only need to be uniquely named in the same workflow.