Kentico CMS 7.0 Developer's Guide

Creating custom action steps

Creating custom action steps

Previous topic Next topic Mail us feedback on this topic!  

Creating custom action steps

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Kentico CMS enables you to write your own actions that you will be able to incorporate into a workflow process. The procedure consists of two steps - writing the code of the action and registering the action into the system.


Writing actions


1. Create a new class and make it inherit from CMS.DocumentEngine.DocumentWorkflowAction.


2. Override the Execute() method from the base class.


3. Write the code that you want to be executed with the action into the Execute method's body.


Action steps can have parameters (settings) specified that you can use to modify their behavior. You can then enter the parameter's values when configuring an action step in the workflow designer. If you want your custom action step to rely on parameters, you can specify them on the Actions tab in Site Manager -> Development -> Workflows. To access the parameter's values in the code of an action, use the GetResolvedParameter method.


To access the data of the document that will go through the action step, use the Node object and its properties.


using System;

using CMS.DocumentEngine;

using CMS.CMSHelper;


public class CustomAction : DocumentWorkflowAction


  public override void Execute()


      // Get the parameter value or assign a default value - an empty string

      string appendText = GetResolvedParameter("MyParameter", "");


      // Append the parameter value to the name of the document

       Node.DocumentName += appendText;


      // Save the changes into the database

      TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

      DocumentHelper.UpdateDocument(Node, tree);





Registering actions in the system


1. Navigate to Site Manager -> Workflows -> Actions and click NewAction New action.


2. Fill in the following mandatory fields:


Display name - name of the action step.

Assembly name - name of the library that contains the action's code.

Class name - full name of the class that contains the action's code.


3. (Optional) Select the module that the action will belong to.


4. (Optional) Define the action's parameters on the Parameters tab.


5. If you created the class in the App_Code folder (or Old_App_Code if you're using web application), you must register it in code to make sure the system loads it.