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

- Enter the name of the Workflow

- 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](https://pushpaganan.home.blog/wp-content/uploads/2019/12/image-12.png?w=649)
- 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.

![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](https://pushpaganan.home.blog/wp-content/uploads/2019/12/image-5.png?w=989)
- 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.

- 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

- 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](https://pushpaganan.home.blog/wp-content/uploads/2019/12/image-8.png?w=1024)
- 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;](https://pushpaganan.home.blog/wp-content/uploads/2019/12/image-9.png?w=885)
- 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:](https://pushpaganan.home.blog/wp-content/uploads/2019/12/image-4.png?w=1024)
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.

- 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.

- 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”