Sitecore – Workflow

Initially, I never had a chance to work with Sitecore Workflows. Most of the time I worked on Sitecore logging in via admin account.

After I came to know about Sitecore Users, Roles and access rights, I started creating users with different privileges. Content Editor and Content Manager. Content Editor can read/write certain items in the Content Tree. And Content Managers would approve or reject their changes. Once the Content Manager Approves the changes, it will be published. Sitecore has  a default work flow that can be set to the items to achieve the above outcome.

But like every feature in Sitecore, one can also customize his own workflow based on our requirement.

I thought of creating a workflow in which the content manager would be notified whenever an item is in his queue waiting for him/her to approve/reject the changes with some minor information about the changes.

To Create a Custom Workflow, Navigate to /sitecore/system/Workflows.

  • Right Click and select Insert->Workflow
Publishing targets 
Set 
Toc 
Templ 
Content Editor 
Insert 
Search 
Duplicate 
Renam( 
Copying 
Sorting 
Experience Editor 
Publish Item 
Console 
Scripts 
Refresh 
You cannot edit thi 
To unprotect the ite 
Workflow 
Insert from template 
Item ID: 
Item name: 
Item path: 
Template: 
Created from: 
Item owner: 
{055926± 
Workf10M 
/sitecore, 
[unknowl 
sit ecore'e
  •  Enter the name of the Workflow
*use it IS 
protect 
Message 
Enter a name forthe new item: 
Guardian News Article* 
OK 
Cancel
  • Each Workflow will have a minimum of three states. Draft ——> Awaiting Approval —->  Approved. Let’s create these states, by right clicking and insert -> states in the created workflow.
Workflows 
Analytics Test 
Analytics Wor 
Guardian Nev 
Approved 
Awaiting A 
Draft 
path Analyzer 
Sample Work 
Experience Ar 
Templates 
:ontent Editor 
Media Li 
X 
Insert 
Search 
Duplicate 
Delete 
Rename 
Copying 
Sorting 
Experience Editor 
Publish Item 
Console 
Refresh 
from: 
mer: 
State 
Insert from template 
Guardian News Article 
'site core/system/Workf 
/sitecore/templates/Sys 
[unknown] 
sitecore\Admin
  • Every workflow must have an default start state and a final state. In our example, the draft state would be the initial state and Approved is the final state. To mark a state as final, the final check box must be selected. Also, once it reaches the final workflow, we will be enabling Auto Publish using Sitecore OOTB command item based on the template /sitecore/templates/System/Workflow/Action and fill in the appropriate Parameters.
Settings 
Tasks 
Toolbox 
Workflows 
Analytics Testing Workflow 
Analytics Workflow 
Guardian News Article 
Approved 
Awaiting Approval 
Draft 
path Analyzer Maps 
Sample Workflow 
Experience Analytics Segment 
Tpmnlarps 
Data 
Final (shared) 
Preview publishing targets - Items in this workflow state can be publis 
Select all Deselect all 
Invert selection 
Description - This text is displayed when you edit items that are in thi'
Toolbox 
Workflows 
Analytics Testing Workfloi 
Analytics Workflow 
Guardian News Article 
Approved 
Auto Publish 
Awaiting Approval 
Draft 
Path Analyzer Maps 
Data 
Type string (shared]: 
Sitecore.Workflows.Simple.PublishAction, Sitecore.Kernel 
Parameters [shared]: 
deep- 1 &related-l 
Advanced
  • For an item to move from one state to another state an action must be triggered. In can be as simple as approve/reject -> Moves to the next/previous state or in our case an email action that triggers an email.
Workflows 
Analytit 
Analytit 
Guardii 
Appt 
Awa 
Drai 
(3 
X 
Insert 
Search 
Duplicate 
Delete 
Rename 
Copying 
Command 
Insert from template
  • Let’s name this as Submit. This command will be displayed in the Review Tab of the Content Ribbon. So that once the editor finishes his changes, clicks on Submit and the corresponding action will be triggered.
  • Under Submit Command, create an Email Action using the template /sitecore/templates/System/Workflow/Email action . Let’s name it as SendMail
Insert from Template 
Select or search for the template you want to use. In the Item Name field, enter a name for the new item. 
Insert 
o 
Cancel 
x 
BROWSE 
Template: 
Item Name: 
SEARCH 
Templates 
Validation 
Workflow 
Action 
Auto Submit Action 
Command 
Email action 
Standard Comment Template 
State 
Validation Action 
Workflow 
Experience Analytics 
Sample 
user Defined 
MySitecore 
[SystemlWorkflow/Email action 
SendMd il
  • Fill in the required details under SendMail item.
Languages 
List 
Publishing 
Settings 
Analytics Testing Workflow 
Workflow 
ELÆrdian News Amcle 
D raft 
Swbt"it 
Maps 
% mple 
Experience Analytics Segrnent 
pushpaganan@hotmail.com 
From 
Subject [shared]: 
Reg: Approval Require-S 
Item Path SitemP8th 
Lansu.ge Sit«nLan84e 
lt.-n Version 
Item URL Si:emurl 
Mail server Ish'redJ: 
Type 
i
  • Notice that under Type field, we gave a class name and the corresponding assembly name. Once, the action is triggered, the control will be passed to this class. This Class must have a Process Method which accepts the WorkFlowPipeline Argument. This Argument contains the information about the Data Item aka the item on which the content editor has worked on and included his changes.
gnaR5pace Mitecore.Fotmdation. Guardian 
public class 
public void args) 
Assert. ArguentNotNu11(args, -args- ) ; 
Processorltem processorltem — args.processorltem; 
if (processorltem! -null) 
Item inneritem = 
String = 
string To — 
string Subject — 
string MailBody - 
string rpst — Servar•"]; 
var hail = 
mail. Subject Subject; 
mail. Body — mailBody; 
"Message" , 
SmtpCIient smtp - 587); 
smtp.EnabIeSsI — true; 
smtp.UseDefauItCredentåaIs = false; 
new 
smtp.CredentiaIs = 
smtp. ; 
inner it&) ; 
"password " ) ; 
public string dataitem, string Field, Item actionltem) 
string — actionltem[FieId]; 
Message - Message. 
message - Message. datait&. Language. Tostring()); 
message - Message. dataiten.Version.ToString()); 
= dataitem.paths. FullPath); 
retur•n Message;
  • Here, our logic for triggering mails can be written.
    • Note: For testing my changes in local, I have made use of Gmail’s SMTP usually every client would have their own SMTP Server configured that can be used for sending mails.
  • I have made use of the Body Field of the Email Action for filling in the relative item’s details via tokens. Hope these are self explanatory.
  • Workflows are usually set while creating the templates for the items – in it’s standard values. I have an Article Page template that follows the just created Workflow.
  • When I create a Article Page, it will be in Guardian News Article Workflow – Draft State
Guardian 
G Home 
404 
500 
Around the World 
Article Page 
Business 
India Today 
Technology 
Sports 
Workflow 
Workflow [shared]: 
Workflows/Guardian News Article 
Workflows/Guardian News Article/Draft 
Lock:

Also, as the item is not in it’s final workflow state, publishing the item doesn’t make any changes. To move the item to the next state in the Workflow, Under Review Menu in the Ribbon, Click on the Submit.

O Desktop 
cms.mysitecore.com/sitecore/shell/default.aspx 
NAVIGATE 
Markup 
VERSIONS 
CONFIGURE 
PRESENTATION 
SECURITY 
Edit 
History 
VIEW 
Submit 
Submit 
MY TOOLBAR 
Reminder 
DEVELOPER 
Archive 
Save 
Search 
HOME 
Spelling 
sitecore 
Content 
REVIEW 
Validation 
proofin% 
ANALYZE 
Subscribe 
Content 
PUBLISH 
Click Edit to lock and edit this item. 
My items 
G Home 
Email 
Mark I 
Guardian 
G Home 
404 
500 
Around the World 
Article Page 
Article Page 
If you publish now, the selected version will not be visible on the Web site because it is not in the final workflow step. 
No other version will be published. 
Quick Info 
Item ID: 
Item name: 
Item path: 
{C9F5ABAF-3AE8467F8C95482E772B6B20) 
Article Page 
/sitecore/contentJMark 1 'Guardian/Article Page
  • Once, you click on the submit button, it will prompt you for a comment. Fill and click on Submit.
  • Once it’s submitted, the mail will be triggered.
  • Once, Content Manager/Admin or other users with privileges to approve/reject logins to Sitecore and access Workbox.
O Analytics Testing Workflow 
O Analvtics Workflow„ 
Guardian News Article 
Items per Page: 
10 
Awaiting Approval - (1 item) 
O A: Article page - (English, version 1) 
Last change: Admin changed from Draft to Awaiting Approval on Monday, December 16, 2019. 
Comments: Test Comment More. 
preview Open Diff Approve Reject 
Approve (selected) 
Draft • (None) 
Approve (all) 
Reject (selected) 
Reject (all)
  • Content Manager can now accept or reject the changes. If it’s approved, it will be auto published. If it’s rejected it will be sent back to draft state.
  • When an item is in Awaiting Approval state, Content Editor cannot make further changes until it’s rejected.

NOTE: As of now, we are sending the email to a predefined E-Mail ID. In the next part, I will post about getting the email id of Sitecore Users with a predefined role (Content Manager/Content Admin) and trigger the emails to those users.

2 thoughts on “Sitecore – Workflow

Leave a comment

Design a site like this with WordPress.com
Get started