The Process Call Chain

Support for main process, sub processes and process routes

If you do not use ExecutionTask you can live with the defaults - as I have done for four years. Skip this page!

Recently I came accross a script that used the following code with ExecutionTask :

ExecutionTask currentProcessExecution = ExecutionManager.getCurrent()
_logger.info( "*** Script hosting process name  : " +  currentProcessExecution.getProcessName())

ExecutionTask t = currentProcessExecution
while( t.getParent() != null) t = t.getParent()

_logger.info( "*** Top-Process Name : " +  t.getProcessName())

// *** Script hosting process name  : subPr.subProcess_01_01
// *** Top-Process Name             : Custom Main Process

The Basics

A script is hosted in a process. This process can be a sub-process of another process(es).

For example:

  • Main Process calls (Level -2)

    • subProcess01 routes to (Level -1)

      • subPr.subProcess_01_01, where the script runs on! (Level 0)

The ExecutionProperties EXECUTION_ID, PROCESS_ID, PROCESS_NAME refer to the script's (hosting) process.

What you need to undestand is, that each process execution has its own ExecutionTask object with different properties, and you can traverse up the hierarchy using the getParent() method.

bool isTopLevelProcess = executionTask.getParent() == null

Process Name = subPr.subProcess_01_01

ExecutionTask currentProcessExecution = ExecutionManager.getCurrent()
+ ExecutionTask Properties - Level=0
- Is Top-Level           = false
- Id                     = execution-59f72f67-95ed-4917-8c54-8d3a3c5f2b02-2024.06.26
- Execution Id           = execution-59f72f67-95ed-4917-8c54-8d3a3c5f2b02-2024.06.26
- Process   Name         = subPr.subProcess_01_01
- Process   Id           = 6a3bfa82-997a-4842-8b6b-1362e07016dc
- Component Id           = 6a3bfa82-997a-4842-8b6b-1362e07016dc
- Start Time             = 1719397726865

Process Name = subProcess01

ExecutionTask level1 = currentProcessExecution.getParent()
+ ExecutionTask Properties - Level=1 - bottom (=0) up to top-level
- Is Top-Level           = false
- Id                     = execution-d41b8cd6-0c92-4edd-9452-77ac20499071-2024.06.26
- Execution Id           = execution-d41b8cd6-0c92-4edd-9452-77ac20499071-2024.06.26
- Process   Name         = subProcess01
- Process   Id           = 2b626af5-4bec-422b-a9ec-a6d0a15090e8
- Component Id           = 2b626af5-4bec-422b-a9ec-a6d0a15090e8
- Start Time             = 1719397726637

Process Name = Main

ExecutionTask level0 = currentProcessExecution.getParent()
+ ExecutionTask Properties - Level=0 - bottom (=0) up to top-level
- Is Top-Level           = false
- Id                     = execution-59f72f67-95ed-4917-8c54-8d3a3c5f2b02-2024.06.26
- Execution Id           = execution-59f72f67-95ed-4917-8c54-8d3a3c5f2b02-2024.06.26
- Process   Name         = Custom Main Process
- Process   Id           = 6a3bfa82-997a-4842-8b6b-1362e07016dc
- Component Id           = 6a3bfa82-997a-4842-8b6b-1362e07016dc
- Start Time             = 1719397726865

How to define a process call hierarchy in a Test

import msPro.scriptease.* // Important

ProcessScriptContext context = new ProcessScriptContext(
inputDocuments: [ ...],

// Override to test process chains 
processCallChain : [
		new ProcessExecutionProperties( "Custom Main Process"),
		new ProcessExecutionProperties( "subProcess01"),
		new ProcessExecutionProperties( "subPr.subProcess_01_01")
])

Process Id (=Component Id) are set to a randowm Guid by default. This can be overridden in the ProcessExecutionProperties constructor.

StartTime and executionId are set a atuomatically.

Last updated