Vous consultez actuellement l'aide de la 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:

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 All to save the updates to the workflow model.

Remarque :

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.

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

Remarque :

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.

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.

    Remarque :

    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 (top left-hand corner of the model panel) to save the update to your workflow model.

    Attention :

    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. Remarque :

    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.

Remarque :

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 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. To open the properties dialog for Step 1 either:

    • Right-click on Step 1 and click Edit.
    • Double-click on Step 1.
  3. In the Common tab enter Validate Content for both the Title and Description.

  4. Open the User/Group tab. Select Administrator (admin) for the User/Group field.

  5. Click OK.

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

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

  7. Open the Or Split for editing.

  8. Configure:

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

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

    • Title: Cancel Publish
    • User/Group: Administrator (admin)
  11. Drag a Process Step to the right-hand branch, open the properties, specify the following values, and click OK:

    • Title: Publish Page
    • Process: select Activate Page. This process publishes the selected page to the publisher instances.
  12. Click Save (top left-hand corner of the model panel) to save all the updates to your workflow model.

    Attention :

    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

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

    Remarque :

    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

    Remarque :

    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 to persist your changes for the workflow model.

    Attention :

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

Function Check()

Remarque :

See Using ECMAScript.

The following sample script returns true if the node is a JCR_PATH located under /content/geometrixx/en:

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

Example: Collecting Data Using Forms and Workflows

With AEM you can associate a workflow with forms (using the Forms components or AEM Forms). It enables you to build processes in which visitors will input information based on multiple forms; for example, an online registration process.

In this section you will create a two-step process to display two characteristics of the "Product of the Day". In the first step, the author will fill out the first form to define the name of the product. In the second step, the author will fill out the second form and specify the designer of the product. The result will be displayed in the Product of the Day page.

Create the Product of the Day page

To create the Product of the Day page:

  1. In the Sites (using the touch-optimized UI, or Websites if using the classic UI) console navigate to Geometrixx Outdoors Site, English, Equipment (/content/geometrixx-outdoors/en/equipment).

  2. Create a new page with the following properties:

    • Template: Content Page without Sidebar
    • Title: Product of the Day
  3. Open the new page for editing. The page has a section with two columns. These two columns each contain a single Text component with no text. Add the following text to the components:

    • Left-hand column: Name:
    • Right-hand column: Designed By:
  4. Add a Text component to each of the two columns, below the existing paragraphs.

    chlImage_1

Obtain the paragraph node names

Use CRXDE Lite to find the name of the nodes (in the repository) that are associated with the paragraphs that you added to the Product of the Day page.

  1. Open CRXDE Lite in your web browser. For example, http://localhost:4502/crx/de

  2. In the node tree, expand the node:

    /content/geometrixx-outdoors/en/equipment/product-of-the-day/jcr:content/par

    Below the par node, the colctrl nodes represent the columns on the Product of the Day page, and the col_break nodes represent the end of the columns. The left-hand column is the first colctrl node, and the right-hand column is the second colctrl node.

  3. Note the name of the second text node after the first colctrl node. The second text node represents the empty text component that you added to the left-hand column.

  4. Note the name of the second text node after the second colctrl node. The second text node represents the empty text component that you added to the right-hand column.

In the following graphic, the text nodes are text_1958199362 and text. Your node names will probably have different identifying characters following the text prefix (text_<id>).

chlImage_1

Create the first form (form1)

To create the first form (form1):

  1. In the Sites (using the touch-optimized UI, or Websites if using the classic UI) console navigate to Geometrixx Outdoors Site, English, Equipment (/content/geometrixx-outdoors/en/equipment).

  2. Create a new page with the following properties:

    • Template: Content Page without Sidebar
    • Title: form1

    Remarque :

    The location of the form pages is not important.

  3. Open the form1 page and delete the 2 Columns component.

  4. Add a Form component to the page (underneath the existing Text components).

  5. Edit the Form Start component and set the following properties (on the Advanced tab) to link the form to a workflow:

    • Action Type: Edit Workflow Controlled Resource(s)
    • Form Identifier: form1

    Click OK.

  6. Add a Text Field component between the Start of Form and the End of Form bars of the Form component.

  7. Edit the Text Field component to specify the following property values:

    • Element Name./jcr:content/par/text_****/text
    • Title: Product Name:

    Remarque :

    text<_id> is the name of the node that represents the empty paragraph on the Product of the Day page. In the previous example, the node name is text_1958199362.

  8. Click OK.

    Remarque :

    When the form is submitted, the value in this field is stored in the <payload-path>/jcr:content/par/text_0/text node.

  9. Add a Workflow Submit Button(s) component immediately below the Text Field component. This component provides the submit button of the form.

chlImage_1

Create the second form (form2)

To create the second form (form2):

  1. In the Sites (using the touch-optimized UI, or Websites if using the classic UI) console navigate to Geometrixx Outdoors Site, English, Equipment (/content/geometrixx-outdoors/en/equipment).

  2. Create a new page with the following properties:

    • Template: Content Page without Sidebar
    • Title: form2

    Remarque :

    The location of the form pages is not important.

  3. Open the form2 page and delete the 2 Columns component.

  4. Add a Form component to the page (underneath the existing Text components).

  5. Edit the Form Start component and set the following properties:

    • Form tab:
      • Thank You Page{payload}.html
    • Advanced tab:
      • Action TypeEdit Workflow Controlled Resource(s)
      • Form Identifier: form2

    Click OK.

  6. Add a Text Field component between the Start of Form and the End of Form bars of the Form component.

  7. Edit the Text Field component to specify the following property values:

    • Element Name./jcr:content/par/text/text
    • Title: Developer Name:

    Remarque :

    text<_id> is the name of the node that represents the empty paragraph on the Product of the Day page. In the previous example, the node name is text.

  8. Click OK.

    Remarque :

    When the form is submitted, the value in this field is stored in the <payload-path>/jcr:content/par/text_2/text node.

  9. Add a Workflow Submit Button(s) component immediately below the Text Field component. This component provides the submit button of the form.

chlImage_1

Create the workflow

To create the workflow:

  1. Create a new workflow with the title Product of the Day and open it for editing.

  2. Delete Step 1.

  3. Drag a Form Participant Step component to the workflow. Specify the following property values:

    • Title: Step 1
    • User/Group: Administrator (admin)
    • Form path: /content/geometrixx-outdoors/en/equipment/form1
  4. Add a Form Participant Step component after Step 1 and specify the following property values:

    • Title: Step 2
    • User/Group: Administrator (admin)
    • Form path: /content/geometrixx-outdoors/en/equipment/form2
  5. Click Save (top left-hand corner of the model panel) to save the updates to your workflow model.

    Attention :

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

potdworkflow

Apply the workflow to the Product of the Day page

  1. Open the Product of the Day page for editing. If the page was still open from a previous procedure then reload it.

  2. Open the Notification Inbox.

  3. Click on the payload link (in this case /content/geometrixx-outdoors/en/equipment/product-of-the-day).

    This will open the form.

  4. In the Product Name field, type Abidjan Water Red, and click next. The form2 page opens.

  5. In the Developer Name field, type Abidjan and click finish.

chlImage_1

Ce produit est distribué sous licence Creative Commons Attribution - Pas d’utilisation commerciale - Partage à l’identique 3.0 non transposé  Les publications Twitter™ et Facebook ne sont pas couvertes par les dispositions Creative Commons.

Mentions légales   |   Politique de confidentialité en ligne