Getting Started

Sub-Workflow Example

Updated: January 2, 2020

A Quick Note About The Sub-workflow Concept

The sub-workflow functionality is the ability to call a workflow from another workflow (creating inception-like workflows), and to pass its variables along the way. The main workflow is suspended while the sub-workflow runs, and resumes when the sub-workflow 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 sub-workflow 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.

How Will We Achieve This?

Easy! We will take advantage of the sub-workflow functionality introduced in Nuxeo 5.7.2.

  • The user will call a workflow.
  • Depending on the document values, we will call a sub-workflow with the corresponding steps.
  • The sub-workflows 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.

We'd love to hear your thoughts!

All fields required