Introduction to workflows

2 comments
Sitecore CMS has very powerful, out of the box functionality which helps with organize content management. This functionality is called workflow. Correctly configured workflows can improve content versioning and publishing processes. I will try to explain what exactly Sitecore workflow is and how to properly configure it.

First of all, workflow determines process of publishing items. It consists of states, commands and actions. Sitecore item which has assigned some workflow after some edition need to go through workflow states from initial state to final state to be able to be published. Moving item to another workflow state is achieved by using commands. The additional part of workflows are actions. Actions can be used to perform some automatic operations after moving item to next workflow state. I know, it seems complicated, but take a look on the below screen.



I think that the best way of explanation workflows will be explanation based on some simple example. Sitecore workflows are located in sitecore/System/Workflows path. In the screen you can see Basic Workflow. It is simple workflow created for this post purposes. As you can see this workflow consists of three states: Draft, In Approval and Approved.

Draft state is initial state of Basic workflow. It is important, because each workflow has to have defined initial state. Workflow can have only one initial state assigned. How to assign initial state to workflow? Inside Data section in Basic Workflow item there is field called Initial State.


Draft state is workflow state, which is assigned to items which were created or edited by content editors. Such items have to be approved by administrator or some user with privileges to accept changes in content made by content editors before publish. It has one command added as children item. I called it Send for approval. As I said earlier command are used to move items from one workflow state to some other workflow state. How do configure command to move item to other state? In command item properties there is field Next state in Data section. As it is showed in below screen Send for approval command moves item from Draft state to In Approval state.


In Approval state is transitional state between Draft and Approved states. In this state changes made by content editors have to be accepted or rejected by proper user which has access to execute commands from this state. State consists of two commands: Approve and Discard. Discard is configured to move item back to Draft state to allow content editor make some changes in item before it will be again send for approval. Approve is configured to change item state to Approved.

If item is moved to Approved workflow state it means that content is well prepared and it is ready to publish it. This state is configured as Final workflow state.


 
Workflow can have multiple final states. In this case Basic Workflow has only one Approved state configured as final. It is required to have at least one final state in workflow, because items in states other than final are not publishable. When item moves to workflow state marked as final it is publishable again.

Approved state has added as children item action called Publish. Actions allow to perform some operations automatically after move to some state or after execute some command. In this case I prepared some simple action which automatically publish item after moving from In Approval state to Approved state. Action is configured to use default Sitecore PublishAction as you can see in below screen in Type string field. To this publishing action can be passed some additional parameters to configure publishing process. In case of Basic Workflow I passed deep=1 parameter, which means that all children of published item should be published with this item. If you need some additional information about PublishAction parameters visit: https://community.sitecore.net/technical_blogs/b/latest_technical_reinnovations/posts/auto-publish-workflow-action-updates


That's ok, but how to assign workflow to specific item? Recommended way to assign workflow to some group of items is set Default Workflow field in Workflow section of template item __Standard Values. Then all items created from this template will have already assigned workflow specified in Default Workflow field.

There are some additional things which should be mentioned if we talk about workflows. Items in final state during next edition by user other than administrator are moved automatically to initial state (in case of Basic Workflow - to Draft state) and item has to go through all workflow approval process from the beginning to be publishable again.  The next important thing is that during each edition of item in final state by non admin user next version of item is created automatically.

I hope that after reading this post you are more familiar with Sitecore workflows and how it can help with content management process and item versioning process. Example of workflow in this post is very simple workflow. Workflows can be more complicated, so it is important to think twice before implementation start. It is good idea to take a piece of paper and prepare some diagram with all states and all available ways to move item from one to another.

2 comments :

Post a Comment