Studio

3- Creating the Main Workflow

Updated: December 16, 2024

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 > Process definitions and click on the New button.
  2. Fill in the fields:

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

Activation 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:

    • A Start node.
    • A Sub Workflow node.
    • 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:
    Expense validation Workflow Before Node Edition
    Expense validation Workflow Before Node Edition

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):

    Main Workflow Subworkflow-field
    Main Workflow Subworkflow-field

  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:

    level1Assignees=@{Fn.concatenateValuesAsNewList(["group:accounting"])}
    level1Assignees=@{Fn.concatenateValuesAsNewList(["Eric"])}
    

    Look at the result below:

    Main Workflow General Node
    Main Workflow General Node

  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.