Skip to content

Feature request: CALL WORKFLOW statement in microflows #136

@engalar

Description

@engalar

Feature Request

MDL microflows cannot call (start) a workflow. The CALL WORKFLOW statement is only supported inside workflow definitions (as a workflow activity), not inside microflows.

Use Case

A microflow creates an entity (e.g., OrderIssue) and needs to programmatically start the corresponding workflow based on business logic:

CREATE MICROFLOW OrderManagement.Tool_CreateIssue (
  $OrderNumber: String,
  $IssueType: String,
  $IssueDescription: String
)
RETURNS String AS $Result
BEGIN
  -- ... create OrderIssue entity ...

  -- This should work but doesn't:
  IF $IssueType = 'DeliveryDelay' THEN
    CALL WORKFLOW OrderManagement.WF_DeliveryDelay (WorkflowContext = $Issue);
  END IF;

  RETURN 'Issue created';
END;

Current Error

Syntax error: no viable alternative at input 'CALL WORKFLOW'

CALL WORKFLOW is parsed inside workflow definitions (e.g., ALTER WORKFLOW ... INSERT ... CALL WORKFLOW SubProcess) but rejected inside CREATE MICROFLOW ... BEGIN ... END.

Current Workaround

Created a Java Action that calls Core.workflows().start():

CREATE JAVA ACTION OrderManagement.StartWorkflowByName(
  WorkflowName: String NOT NULL,
  ContextObject: OrderManagement.OrderIssue NOT NULL
) RETURNS Boolean
AS $$
IContext context = getContext();
com.mendix.core.Core.workflows().start(context, WorkflowName, ContextObject.getMendixObject());
return true;
$$;

Then in the microflow:

$WfOk = CALL JAVA ACTION OrderManagement.StartWorkflowByName(
  WorkflowName = 'OrderManagement.WF_DeliveryDelay',
  ContextObject = $Issue
);

This works but requires a custom Java Action for something Studio Pro provides as a built-in microflow activity ("Call workflow").

Expected Syntax

-- Option A: Direct call (matches Studio Pro's "Call workflow" activity)
CALL WORKFLOW OrderManagement.WF_DeliveryDelay (WorkflowContext = $Issue);

-- Option B: With return value (workflow instance)
$WorkflowInstance = CALL WORKFLOW OrderManagement.WF_DeliveryDelay (WorkflowContext = $Issue);

Context

In Studio Pro, the "Call workflow" activity is a first-class microflow activity, alongside "Call microflow" and "Call Java action". MDL supports the latter two in microflows but not "Call workflow".

The CALL WORKFLOW statement already exists in the MDL grammar for workflow-to-workflow calls (sub-workflows). Extending it to microflows would complete the coverage.

Environment

  • mxcli: 0.1.0
  • Mendix: 11.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions