All Articles

Sitecore Workflows - Custom Workflow Actions

This article will cover how we can create a custom workflow action for Workflows with Sitecore.

OOTB Submit Actions

Sitecore offers a few OOTB Submit Actions which can be used as per your requirements.

  1. Auto Submit Action This action can be utilized to automatically submit an item if it is saved by a user from a certain role. It accepts the Type (which will remain the same), Next State and the Role Name. Template Path: /sitecore/templates/System/Workflow/Auto Submit Action
  2. Validation Action It can be used to refuse a change in state if the item has validation errors. You can mention the maximum allowed result - Warning, Error etc. and the messages to be shown in case of errors. Template Path: /sitecore/templates/System/Workflow/Validation Action
  3. Auto Publish Auto Publish, as the name suggests can be used to trigger a publish on the item if it moves to a certain final state. It accepts parameters such as deep (To publish with subitems) and smart (For a smart publish). Template Path: /sitecore/templates/System/Workflow/Action Type: Sitecore.Workflows.Simple.PublishAction, Sitecore.Kernel Parameters: deep=1&smart=1 (Set to 0 if false, or exclude it).
  4. Email Action It can be used to send an email to mentioned emails to inform a state change. Template Path: /sitecore/templates/System/Workflow/Email action

Creating your own custom workflow action

There are 2 steps in creating your custom workflow action:

  1. Create a template with the fields that you need to be passed to the workflow action code. The Type field is a mandatory field.
  2. Create a class with a Process method accepting a parameter of type WorkflowPipelineArgs. The fully qualified name of this class will be populated in the Type field of the action item.

The class will look like below:

using Sitecore.Diagnostics;
using Sitecore.Workflows.Simple;
using System;
using Sitecore.Data.Items;

namespace Foundation.Workflow.Actions
    public class CustomWorkflowAction
        public void Process(WorkflowPipelineArgs args)
                Assert.ArgumentNotNull(args, "args");
                Item dataItem = args.DataItem; // This will be the page item
                ProcessorItem processorItem = args.ProcessorItem;
                Item actionItem = processorItem?.InnerItem; // This will be the action item itself
		string myValue = actionItem["My Field Name"]; // Access the values from the action like this
			Your code goes here
            catch (Exception ex)
                Log.Error(ex.Message, this);


Now, you can add the action item under the workflow command on which you need it to be triggered. Remember to add the value for the Type field as the fully qualified name of the class.

Happy Sitecoring!

Published Oct 13, 2023

Sitecore MVP Technology 2024-23. Web Developer with rich experience in Sitecore and ASP.NET MVC.