Dynamic Workflow Activity
The Workflow Activity is designed to trigger a fixed, preconfigured workflow definition. However, when the workflow to be triggered depends on specific conditions, managing multiple Workflow Activities and their inclusion logic can become inefficient—especially when the logic is complex. To address this challenge, Casewhere introduces the Dynamic Workflow Activity, enabling workflows to be triggered dynamically based on runtime conditions.
The following screenshot demonstrates how complex the setup can become without the Dynamic Workflow Activity.
Configuration
The Dynamic Workflow Activity can be added to the workflow definition just like any other workflow activity.
The activity configuration appears as follows:
Output Workflow Variable: Defines a variable to store the value returned by the workflow.
Queue Workflow: When enabled, the workflow is queued for background execution.
- Priority: Used to determine the execution order, applicable only to queued workflows.
Script: A script that executes custom logic to determine the workflow definition, process and input, returning a DynamicWorkflowExpressionResult
. Casewhere will use this information to trigger the corresponding workflow.
var workflowDefinitionName = "CwAmt Runtime Approve Application";
var processName = "CwAmtApplicationProcess";
// Your complex execution logic goes here
return new DynamicWorkflowExpressionResult()
{
WorkflowDefinitionName = workflowDefinitionName,
ProcessName = processName, // No need to specify the "ProcessName" if the triggered workflow definition is "Edit-Case"
InputParameters = new Dictionary<string, string>() {
{ "applicationId" , ctx.Input["Id"] }
}
};
In the example above, the triggered workflow can access the passed data using ctx.Input
or ctx.Ref("applicationId")
.