You're viewing help content for version:

You create a workflow model to define the series of steps executed when a user starts the workflow. When a user starts a workflow, an instance is started; this is a copy of the workflow model at that point in time.

When you first create a new workflow model it contains:

  • The steps, Flow Start and Flow End.
    These represent the beginning and end of the workflow. These steps are required and cannot be edited/removed. 
  • An example Participant step named Step 1.
    This step is configured to assign a work item to the admin user.  Edit or delete this step, and add steps as required.

Creating a New Workflow

Creating a New Workflow - Touch-Optimized UI

  1. Select Create, then Create Model.

  2. The Add Workflow Model dialog appears. Enter the Title and Name (optional) before selecting Done.

  3. The new model is listed in the Workflow Models console.

  4. Select your new workflow, then use Edit to open it for configuration:

    chlimage_1

Creating a New Workflow - Classic UI

  1. Open the Workflow console. For example, http://localhost:4502/libs/cq/workflow/content/console.html.
  2. On the Models tab, click New. The New Workflow dialog opens.
  3. Type the title for your workflow and click OK.
  4. The new model appears in the Models tab.
  5. Select your model, then click Edit to open it for configuration.

Editing an Existing Workflow

Editing an existing workflow can be done in the same manner as creating a workflow - after the actual create/new action. Again, it is dependent on the UI you are using:

Caution:

When you make any changes to the workflow you must use Save (left in the editor toolbar) to persist them to the workflow model; even when individual dialogs (for steps, etc.) have had their own save options.

Caution:

It is not recommended to edit any of the out-of-the-box workflows as you would (potentially) have to re-apply the edits after applying any form of update (e.g upgrade, service pack, feature pack, hot-fix amongst others).  

It is recommended to either clone and modify the workflow model or, for specific scenarios, to use overlays; for example, see Example: Customized Request for Activation

Creating a Transient Workflow

You can create a Transient workflow model when creating a new model, or by editing an existing one:

  1. Create and/or edit the workflow model according to the UI you are using.

  2. Select the Page tab of sidekick, followed by Page Properties... to open the dialog.

  3. In the dialog activate Transient Workflow (or deactivate if required):

    chlimage_1
  4. Click OK to save this setting, followed by Save (editor toolbar) to save the updates to the workflow model.

Note:

When you run a workflow in transient mode AEM does not store any workflow history. Therefore, Timeline does not display any information related to that workflow.

Configuring a Workflow for Multi Resource Support

You can configure a workflow model for Multi Resource Support when creating a new model, or by editing an existing one:

  1. Create and/or edit the workflow model according to the UI you are using.

  2. Select the Page tab of sidekick, followed by Page Properties... to open the dialog.

  3. In the dialog activate Multi Resource Support (or deactivate if required):

    chlimage_1
  4. Click OK to save this setting, followed by Save (editor toolbar) to save the updates to the workflow model.

Configuring Workflow Stages (that show Workflow Progress)

Workflow Stages help visualize the progress of a workflow when handling tasks.

Caution:

If workflow stages are defined in Page Properties, but not used for any of the workflow steps, then the progress bar will not show any progress (regardless of the current workflow step).

The stages to be available are defined in the workflow models; existing workflow models can be updated to include stage definitions. You can define any number of stages for the workflow model. 

To define Stages for your workflow:

  1. Open your workflow model for editing.

  2. Open the Page Properties, then the Stages tab:

  3. Add (and position) your required Stages. You can define any number of stages for the workflow model. 

    For example:

    chlimage_1
  4. Click OK to save the properties.

  5. Assign a stage to each of the steps in the workflow model. 

    chlimage_1

    A stage can be assigned to more than one step. For example:

    Step Stage                              
    Step 1 Create                              
    Step 2 Create                              
    Step 3 Review                              
    Step 4 Approve                              
    Step 5 Approve                              
    Step 6 Complete                              
    chlimage_1
  6. Click Save (editor toolbar) to save the updates to your workflow model.

    Caution:

    Even when you have configured and saved updates to the properties and/or individual steps, these will not be persisted to the workflow model until you click Save.

Adding a Step to a Model

You will need to add steps to your model to represent the activity to perform - each step performs a specific activity. A selection of step components are available in a standard AEM instance. 

When you edit a model, the available steps appear in the various groups of the Components tab in the workflow sidekick.

chlimage_1

Note:

For information about the primary step components that are installed with AEM, see Workflow Steps Reference.

To add steps to your workflow model:

  1. Open your workflow model for editing.

  2. Drag the required workflow step component from the sidekick to the model. A checkmark icon on the component indicates a valid drop location.

    chlimage_1
  3. At run time, steps are executed in the order in which they appear in the model. After adding step components, you can drag them to a different location in the model.

  4. Click Save (editor toolbar) to save the update to your workflow model.

    Caution:

    Even when you have configured and saved updates to the individual step, these will not be persisted to the workflow model until you click Save.

Editing a Workflow Step

You can Edit step components to configure and customize their behavior using the Step Properties dialogs.

  1. To open the Step Properties dialog for a step either:

    • Right-click the step in the workflow model and click Edit.
    • Double-click on the step.

    Note:

    For information about the primary step components that are installed with AEM, see Workflow Steps Reference.

  2. Configure the Step Properties as required; depending on the step type there may be several tabs available. For example, the default Participant Step, present in a new workflow as Step 1:

    workflowstepedit
  3. Click OK to save your updates to the step.

  4. Click Save (editor toolbar) to save the update to your workflow model.

    Caution:

    Although you have saved updates to the individual step, these will not be persisted to the workflow model until you click Save.

Debugging and Testing Workflows

You can configure AEM to display DEBUG messages in the log files:

  1. Open the Configuration Manager of the Web Console; for example:

    http://localhost:4502/system/console/configMgr

  2. Note:

    See Logging for further information.

  3. When the development is finished, set the Log Level back to Info.

Test your new workflow as follows:

  1. Start your workflow model from the console.
  2. Define the Payload and click OK.
  3. Take actions as required so that the workflow proceeds.
  4. Monitor the log files while the workflow is running.

Note:

It is a good practice when debugging a workflow to test the workflow with a variety of payload types; including types that are different to the one for which it has been developed. For example, if you intend your workflow to deal with Assets, test it by setting a Page as payload and make sure that it does not throw errors.

Using Workflows to Process Form Submissions

You can configure a form to be processed by the selected workflow. When users submit the form, a new workflow instance is created with the data of the form submission as its payload.

To configure the workflow to be used with your form:

  1. Create a new page and open it for editing.

  2. Add a Form component to the page.

  3. Edit the Start of Form component that appeared in the page.

  4. Use Start Workflow to select the desired workflow from those available:

    workfloweditform
  5. Click OK to confirm the new form configuration.

Example: Creating a (Simple) Workflow to Accept or Reject a Request for Publication

To illustrate some of the possibilities for creating a workflow, the following example creates a variation of the Publish Example workflow.

  1. Create a new workflow model.

    The new workflow will contain:

    • Flow Start
    • Step 1
    • Flow End
  2. Delete Step 1 (as it is the wrong step type for this example):

    • Right-click on the step and click Delete. Confirm the action.
  3. From the Workflow section of the sidekick Components tab, drag a Participant Step onto the workflow and position it between Flow Start and Flow End.

  4. To open the properties dialog either:

    • Right-click on the participant step and click Edit.
    • Double-click on participant step.
  5. In the Common tab enter Validate Content for both the Title and Description.

  6. Open the User/Group tab:

    • Select Administrator (admin) for the User/Group field.
    • Activate Email to have the user notified by email.
  7. Click OK.

    You will be returned to the overview of the workflow model, here the participant step will have been renamed to Validate Content.

  8. Drag an Or Split onto the workflow and position it between Validate Content and Flow End.

  9. Open the Or Split for editing.

  10. Configure:

    • Common: select 2 Branches
    • Branch 1: select Default Route.
    • Branch 2: ensure Default Route is not selected.
  11. Click OK to save your updates to the OR Split.

  12. Drag a Participant Step to the left-hand branch, open the properties, specify the following values, and click OK:

    • Title: Reject Publish Request
    • User/Group: for example, projects-administrators
    • Email: Activate to have the user notified by email.
  13. Drag a Process Step to the right-hand branch, open the properties, specify the following values, and click OK:

    • Title: Publish Page as Requested
    • Process: select Activate Page. This process publishes the selected page to the publisher instances.
  14. Click Save (editor toolbar) to save all the updates to your workflow model.

    Caution:

    Although you have saved updates to the individual steps, these will not be persisted to the workflow model until you click Save.

    Your new workflow model will look like:

    workflowexample
  15. Apply this workflow to your page, so that when the user moves to Complete the Validate Content step, they can select whether they want to Publish Page as Requested, or Reject Publish Request.

    chlimage_1

Example: Defining a Rule for an OR Split

OR Split steps allow you to introduce conditional processing paths into your workflow.

To define an OR rule, proceed as follows:

  1. Create two scripts and save them in the repository, for example under:

    /apps/myapp/workflow/scripts

    Note:

    The scripts must have a function check() that returns a boolean.

  2. Edit the workflow and add the OR Split to the model.

  3. Edit the properties of Branch 1 of the OR Split:

    • Define this as the Default Route by setting the Value to true.
    • As Rule, set the path to the script. For example:
      /apps/myapp/workflow/scripts/myscript1.ecma

    Note:

    You can switch the branch order if required.

  4. Edit the properties of the Branch 2 of the OR Split.

    • As Rule, set the path to the other script. For example:
      /apps/myapp/workflow/scripts/myscript2.ecma
  5. Set the properties of the individual steps in each branch. Make sure the User/Group is set.

  6. Click Save (editor toolbar) to persist your changes for the workflow model.

    Caution:

    Although you have saved updates to the individual steps, these will not be persisted to the workflow model until you click Save.

Function Check()

Note:

See Using ECMAScript.

The following sample script returns true if the node is a JCR_PATH located under /content/we-retail/us/en:

function check() {
    if (workflowData.getPayloadType() == "JCR_PATH") {
	     var path = workflowData.getPayload().toString();
	     var node = jcrSession.getItem(path);
	     
	     if (node.getPath().indexOf("/content/we-retail/us/en") >= 0) {
	     	return true;
	     } else {
	     	return false;
	     }	
     } else {
     	return false;
     }
}

Example: Customized Request for Activation

You can customize any of the out-of-the-box workflows. To have customized behavior you overlay details of the appropriate workflow.

For example, Request for Activation. This workflow is used for publishing pages within Sites and is automatically triggered when a content author does not have the appropriate replication rights. See Customizing Page Authoring - Customizing the Request for Activation Workflow for further details.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy