Guides and Tutorials

3- Creating the Main Workflow

Updated: July 17, 2023

This document is part of the Sub Workflow Example project series.

What Will We Do In this Step?

We will create the main workflow that will call a subworkflow depending on the document's metadata, and pass it variables along the way.

Creating the Workflow

  1. In Nuxeo Studio, go to Workflow > Workflow definitions and click on the New button.
  2. Fill in the fields:

    1. Feature ID: expenseValidation
    2. Label: Expense validation
    3. (Optional) Description: Request your expense validation.
  3. Click on the Next button.

Availability Tab

This workflow will be a wrapper for the subworkflows. So contrarily to the previous ones we created, it should be visible to the users.

  1. In the "Current user has one of the permissions" list, choose Edit.
  2. In the "Current document has one of the types" list, choose Expense.
  3. In the "Current document has life cycle" field, type project. We wouldn't like to launch the workflow on validated expenses.
  4. Save your modifications.

Graph Tab

  1. Drag and drop the following nodes on your graph:

    1. A Start node.
    2. A Sub Workflow node.
    3. An end node (Stop).
  2. Link the start node's output transition to the subworkflow node.
  3. Link the subworkflow's output transition to the end node.
  4. Save your modifications. Your graph should look like this:

Edit the Sub Workflow Node

General Tab

Set the following values:

  1. Title: Validation request

  2. Workflow: We will use an MVEL expression to determine which workflow should be run. Type the following expression in this field: @{Document["expense:amount"] < 100 && Document["expense:expensetype"] != 'Misc' ? 'subOneLevelValidation' : 'subTwoLevelsValidation'} This implements our business logic rule, by checking the expense's amount and its type. If under $100 and not in the misc category, then we call a one level validation, otherwise a two-level validation. Result below (as seen in the expression editor because it is a rather large expression):

  3. Workflow variables: This field determines which variables we will send to the sub workflow that is called. Note that to be able to use it in your subworkflow, it has to be set in the subworkflow Variables tab; as we did this already in the previous step, we're fine. Each value has to be set on a separate line, so we will fill this field as following:


    Look at the result below:

  4. Save your modifications in the node and on the graph.

You are now all set! This tutorial is merely a basic example of what can be achieved with the sub workflow functionality; the rest is up to your imagination.