Creating custom action workflow steps

Enterprise license required

Features described on this page require the Kentico Xperience Enterprise license.

Xperience enables developers to create custom actions that can be incorporated into advanced workflow processes. 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 DocumentWorkflowAction (available in the CMS.DocumentEngine namespace).

    Class location

    Add the class into a custom assembly (Class Library project) within your Xperience administration solution. Add the appropriate references between the assembly and the main Xperience project.

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

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

Action steps can have parameters (settings) specified that you can use to modify their behavior. Users can then enter values for the parameters 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 of the Workflows application. To access the parameter’s values in the code of an action, use the GetResolvedParameter method.

To access the data of the page going through the action step, use the Node property and its members (available from the DocumentWorkflowAction base class).




using CMS.DocumentEngine;

public class CustomAction : DocumentWorkflowAction
{
    public override void Execute()
    {
        // Gets the parameter value or assigns a default value - an empty string
        string appendText = GetResolvedParameter("MyParameter", "");

        // Appends the parameter value to the name of the page
        Node.DocumentName += appendText;

        // Saves the changes into the database
        Node.Update();
    }
}


Registering actions in the system

  1. Open the Workflows application.
  2. Select the Actions tab.
  3. Click New action.
  4. Fill in the following mandatory fields:
    • Display name – name of the action step.
    • Action provider - Assembly name – name of the library (assembly) that contains the action’s code.
    • Action provider - Class – full name of the class that contains the action’s code (including namespaces).
  5. Click Save.
  6. (Optional) Define the action’s parameters on the Parameters tab.