Add commands and actions to states

Version: 10.4

You can add actions and commands to states, and you can also add actions to commands.

Add a command to a state

To add a command to a state:

  1. Click the Product Review workflow.

  2. Right-click the Draft state, then click Insert, Command and name the new command Submit.

    Add a command named Submit to the Draft state.
  3. Click the Submit command, and select Awaiting Approval in the Next state field.

    Set the Next state field of the Submit command to the Awaiting Approval state.

Now, create the following commands under the Awaiting Approval state by repeating step 1-3.

  • Approve with Next state set to Approved.

  • Reject with Next state set to Draft.

Add an action to a state or command

To add an action to a state or command:

  1. Click the Product Review workflow, the Awaiting Approval state.

  2. Right-click the Approve command, then click Insert, Action, and name the new command Validation Action.

    Add a Validation Action action to the Approve command.
  3. Click the Validation Action action and enter Sitecore.Workflows.Simple.ValidatorsAction, Sitecore.Kernel in the Type field. Enter Warning in the Max Result Allowed field.

    The Validation Action item in the content tree
  4. Fill out the Result fields with the messages you want a user to see in case of validation errors, such as “You cannot approve an item with validation errors”.

In a similar way, add an action named Auto Publish to the Approved state but enter Sitecore.Workflows.Simple.PublishAction, Sitecore.Kernel in the Type field and deep=1&smart=1 in the Parameters field.

Create an Auto Publish action under the Approved state.

Define the final state

To define the final state, click the state you want to be the final state in your workflow and select the Final checkbox.

Select the Final checkbox in the final state.

In this example, you can only publish items that are in the Approved state.

Do you have some feedback for us?

If you have suggestions for improving this article,