Sitecore Workflow QuickStart Guide: Part-1

This series is divided into three parts:

Part 1 : Sitecore Workflow QuickStart Guide : Part-1
Part 2 : Sitecore Workflow QuickStart Guide : Part-2
Part 3 : Sitecore Workflow QuickStart Guide : Part-3

Workflow in sitecore ensures that items move through a predefined set of states ­­­­before they are publishable, usually it’s to ensure that content is reviewed appropriately before publishing on the live website.
Important things to consider in workflow are
1)      State
2)      Command
3)      Action
We will assign workflow to item template’s standard values so all the items that are published based on that template enters into the workflow which has to be followed.

In real scenario content item is created by one user it is then submitted and reviewed by another user, who will approve which will change the state to Approved then finally the publisher will approve and publish the item. 
Workflow_1
Workflow Item follows ERP Formula.
Editor <-> Reviewer <-> Publisher

Editor creates item. Reviewer Approves item or Reject item. If Item is rejected by reviewer then it will go back to Editor. If reviewer approves item it will then be in Approve and Publish state and can be approved and published by Publisher.
At the end we should have the following workflow implementation in sitecore:


1)      Creating workflow
Create a workflow using /sitecore/System/Workflows/ and enter the name 
Before assigning the initial state to this workflow, we first have to create the state.

2)      Creating Workflow States
For that select workflow definition item and the select Insert from Template command and create the new workflow state using the /System/Workflow/State template. Call the first state “Draft”.

Creating_Workflow_2_1

Similarly create three more workflow states –Awaiting Approval, Approve and Publish, Done.
It’s up to the requirement whether you have to create two levels or three of workflow. Here we will look at three levels of workflow where in as sitecore item reaches its final state i.e. Done then it will Auto Publish to Web Database.

At the end of this step you should have the following:
Sitecore_Workflow_2_2
Now let’s set the Initial State as a Draft.

3)      Creating Workflow Commands
To add command to a workflow state:
Creating_Workflow_Commands_3_1

Creating_Workflow_Commands_3_2Create commands as shown in below diagram.






Creating_Workflow_Commands_3_3










Note: You can give any valid name to commands. Commands will appear to user. For example here
publisher will have access to Approve and Publish State where we have provided Approve and Reject
options, instead you can provide Approve and Publish or Reject.

Now let's set the transition from one state to another with the help of commands.
Click on Submit Command in Draft State and set the Next State to Awaiting Approval State.


Creating_Workflow_Commands_3_4
Similarly select Approve in Awaiting Approval and set the Next State to Approve and Publish.
Creating_Workflow_Commands_3_5
Select Reject in Awaiting Approval State and set the Next State to Draft.
Creating_Workflow_Commands_3_6

Similarly from Approve and Publish state Approve Command will point the Next state as Done and
Reject Command will point the Next State to Awaiting Approval State.

Note: Suppress Comment: This checkbox defines whether or not users are prompted to enter a comment when a workflow command is executed. If the checkbox is cleared, users are prompted. If the checkbox is selected, users are not prompted.

4)      Creating Workflow Actions
a.       Validation Actions

Select Approve Workflow Command, Right click and select Insert from Template Command and create the new workflow action using /System/Workflow/Validation Action template. Call the new command “Validation Action”.

Creating_Workflow_Actions_4_1

Creating_Workflow_Actions_4_2

You will get the below screen. Enter the following information in Fields.

Type Field: Sitecore.Workflows.Simple.ValidatorsAction,Sitecore.Kernel.
Max Result Allowed: Warning

The maximum response from the validator.
The possible values are:
Unknown
Valid
Suggestion
Warning
Error
CriticalError
FatalError
If the value of this field is “Error”, then items which have errors will pass, but the items which have critical errors will not pass.
Fill the error results with proper error messages that you want a user to see in case of validation errors.


Similarly add Validation Action at Approve in Approve and Publish State.

b.       Auto Publish Action



The data section of this workflow action contains the following fields:
Type: The namespace.class, assembly name of the implementation class.
            For Example: Sitecore.Workflows.Simple.PublishAction, Sitecore.Kernel

Parameters: The deep parameter that specifies whether or not the child items should be published.
                deep=1 --- publish children
                deep=0 --- do not publish children
                related=1 --- publish children (Sitecore 7.2 onwards)



5)      Defining Workflow Final State
Select the state which is supposed to be the final state in workflow and select the Final Checkbox in the Data field:

Only those items which are approved by publisher in Approve and Publish state will move on to Done State of workflow and it will be published automatically.

6)      Assigning workflow to a Template
It is always the best practice to assign the workflow to the standard values item of a template.

Select the Standard Fields Checkbox.



Leave the Workflow and the State field’s blank, as they will be filled automatically upon the item creation basing on the workflow settings. Leave the Lock field as it is.

Save the template and now it is ready to use with workflow support. First phase of creating a workflow is complete.

Now let’s see how to use workflow for creating-reviewing-publishing items in Part-2


Labels: , ,