The Workflow module

Last updated on
9 January 2024

This documentation needs work. See "Help improve this page" in the sidebar.

The Workflow Module

Project page: http://drupal.org/project/workflow


The workflow module enables you to create arbitrary workflows in Drupal and associate them with entities. A Workflow is made up of workflow states. Moving from one state to another is called a transition.


Installation

  1. Place the entire workflow directory into your Drupal modules directory.
    • D7: sites/all/modules
    • D8: modules
  2. Go to the Modules administration page of your installation, and enable the following workflow submodules:
    • D7/D8:
      • Workflow API module; this will create the necessary database tables;
      • Workflow UI module lets you create new workflows. You can also create workflows from code or import them via Features.
      • Workflow Field (available as of version 7.x-2.0) allows you to add fields of type 'workflow' to your entity types. If you create a new field type, you can choose which workflow to attach to this new field.
      • Workflow Node is the 'good old' way of working. You only enable this submodule if you are already using the Workflow module with version 7.x-1.2 or earlier.
    • D9/D10:
  3. If you want anyone besides the administrative user to be able to configure workflows (usually a bad idea), they must be given the "administer workflow" access permission.
    • D7 to D10: Administration > People > Permissions tab, /admin/people/permissions

    When the module is enabled and the user has the "administer workflow" permission, a "Workflow" menu should appear in the menu system.

    • D7: Administration > Configuration > Workflow, /admin/config/workflow/workflow
    • D8: Administration > Configuration > Workflow, /admin/config/workflow

    You may also allow only some users to schedule transitions in the future. Select the "schedule workflow transitions" permission to allow transitions.

  4. You may limit which roles show up in the workflow edit screen by using the "Participate in workflow" permission.
    • D7/D8: Administration > People. Permissions tab, /admin/people/permissions

Getting started

Note: Recent changes to the admin UI have affected these instructions a bit. You should still be able to find your way around though.

  • Let's create a new workflow
    • D7: Navigate to - Administer > Site building > Workflow
    • D8: Navigate to - Administration > Configuration > Workflow
  • Click on the "Add workflow" tab.
  • We'll start simple. Give the workflow a label of "Draft-Done" and save.
  • Now lets add some workflow states to our workflow. Click the States tab, enter "Draft" and click Save. Repeat the process for "Done".
  • We now have a workflow with two states, "Draft" and "Done". Now we have to tell each state which other states it can move to. With only two states, this is easy.
  • Click on the Transitions tab to edit the workflow and see its state transitions.
  • The "FROM \ TO" column lists all states. To the right are columns for each state. Within each cell is a list of roles with checkboxes.
  • Although this is initially is confusing it's easiest to understand if you read rows across from the left. For example, we start with the "(Creation)" state. Who may move a node from its "(Creation)" state to the "Draft" state? Well, the author of the node, for one. So check the "(Author)" checkbox.
  • Who may move the node from the "Draft" state to the "Done" state? This is up to you. If you want authors to be able to do this, check the "(Author)" checkbox under the "Done" state. If you had another role, say "editor", that you wanted to give the ability to transition a node to "Done", you'd check the checkbox next to the "editor" role and not the author role. In this scenario authors would turn in drafts and editors would say when they are "Done".
  • Be sure to click the Save button to save your settings.
  • Now let's tell Drupal which node types should use this workflow:
    • D7: Navigate to - Administer > Site building > Workflows
    • D8: Navigate to - Administration > Configuration > Workflow
  • If you are using a 7.x-1.x version, you need to activate the Workflow Node module. If you are using a 7.x-2.x or D8, you need to activate the Workflow Field module (recommended).
    If you activate Workflow Node, you'll find a 'type map' section.
    If you activate Workflow Field, you will be able to assign a workflow to a content type, by creating in the content type form a field of type 'workflow'. In there, you'll be able to choose the workflow of your choice. Go to Administration > Structure > Content Types > Article. Add a field with 'workflow' type and follow instructions.
  • Now we could add an action (previously configured using the trigger module). Click on the Actions link above your workflow. Add the action to the transition.
  • Now create a new story by going to Create content > Story. If there is no sign of a workflow interface here, don't panic. The interface is only displayed if there is more than one state to which the user can move the node (why bother the user with a form with only one selection?) Click Submit to create the story.
  • You can see the state the node is in and the history of state changes by clicking on the Workflow tab while viewing a node.
  • Changing the state to "done" and clicking Submit will fire the action you set up earlier.

Help improve this page

Page status: Needs work

You can: