Guides and Tutorials

Sub Workflow Example

Updated: July 17, 2023

A Quick Note About The Subworkflow Concept

The subworkflow functionality is the ability to call a workflow from another workflow (creating inception-like workflows), and to pass it variables along the way. The main workflow is suspended while the subworkflow runs, and resumes when the subworkflow ends.

This functionality is a great asset as it allows you to reuse your workflows and imagine powerful combinations. The best point is that you can dynamically choose the subworkflow that should be called using an MVEL expression.

Use Case

The company SuperTech wants to implement an expense report validation workflow, with the following rules:

  • Users should be able to fill in their expenses and attach the corresponding receipt.
  • Each expense should be validated separately.
  • Expense type can be chosen from a list (transportation, hotel or misc).
  • Expenses of 100 dollars or more have to be validated by the accounting service and the general manager, only by the accounting service if less.
  • If the document is validated, set its status to approved.
  • If the document is rejected, end the workflow.

Please note that this tutorial will mainly focus on explaining new workflow functionalities appeared with Nuxeo 5.7.2. If you are using an older version of Nuxeo platform and / or if you wish to learn more about workflow basics, you may have a look at the simple workflow example.

How Will We Achieve This?

Easy! We will take advantage of the subworkflow functionality introduced in Nuxeo 5.7.2.

  • The user will call a workflow.
  • Depending on the document values, we will call a subworkflow with the corresponding steps.
  • The subworkflows will be made generic so that they can also be used in another context.

How Are We Going To Create It?

This project will be divided in three steps:

  1. Creating the Expense document type
  2. Creating the validation sub workflows (called automatically depending on the document values)
  3. Creating the main workflow (called by the user)

Ready? So let's start with the Expense document type creation.