Creating Scripts for Custom Application in Process Flow
Using Process Flow in a Template
While creating a Process Flow, in the Process Designer, write the following script in the Service exception field under the OnException Scripts tab.

![]() | import org.apache.commons.lang.exception.ExceptionUtils; Throwable rootCause = ExceptionUtils.getRootCause(exception); |
Process Flow Calling Another Process Flow
If the Process Flow is further calling another Process Flow, you must create a custom plugin using the below JavaScript. After you have created a custom plugin, use it in the Process Flow just before a Call or Spawn activity. In case there are multiple Call or Spawn activities in a Process Flow, you need to add a Custom Plugin before every Call or Spawn activity.
JavaScript for Custom Plugin to set child context Param and other required information to call another process flow:
-
When streaming is passed to child flow in File Mode:
where,
ACTION_NAME is the name of the call or spawn.
for example,

Ensure that the source activity is File Source when streaming is passed in File Mode and eventContextEnable is true.
Ensure that you have provided the <<action_name>> in double quotes (" ").</action_name>
When data encryption at rest (EAR) is enabled, the data that the child Process Flow receives is encrypted. To decrypt this data, add a variable in the following format, setting its value to true in the child Process Flow.TX.SourceEncryptedAtRest_<SOURCE_ENTITY_NAME> -
When streaming is passed to child flow in Memory Mode:
where,
ACTION_NAME is the name of the call or spawn.
context****VarName is the name of the context variable that will be used as a Key to put stream data in context.

In Memory mode, it is mandatory to use Context Source in child flow, and eventContextEnable must be false.
Ensure that you have provided the <<action_name>> and contextVarName in double quotes (" ").</action_name> -
When no Stream is passed to child flow:
where,
ACTION_NAME is the name of the call or spawn.

Ensure that you have provided the <<action_name>> in double quotes (" ").</action_name>
JavaScript to check if child flow is Aborted or not:
where,
resultCtxVarName is the name of the context variable that contains the status of the sub-flow.
**JavaScript for Custom plugin to abort parent flow:
**
Process Flow Design
Following are the sample designs of the Process Flow, calling a Transaction through Call or Spawn action:
Using SIngle Call

Using Multiple Call

Using Single Spawn

Using Multiple Spawn
