Here’s a comprehensive solution addressing all three aspects: exception microflow configuration, workflow state transitions, and RPA bot error propagation.
1. Exception Microflow Configuration:
Create a dedicated error handling microflow that wraps your RPA bot execution:
TRY
CALL RPA_Connector.ExecuteBot($Task, $BotConfig)
CALL WorkflowCommons.CompleteTask($Task)
CATCH
CALL WorkflowCommons.SetTaskStatus($Task, 'Failed')
CALL System.CreateLogMessage('RPA bot failed: ' + $Error)
COMMIT $Task
END
2. Workflow State Transitions:
The critical piece is using WorkflowCommons.SetTaskStatus rather than direct entity updates. This ensures the workflow engine’s state machine is properly notified. Configure your workflow to have explicit failure paths that allow retry or escalation. In your workflow definition, add a conditional split after the RPA task that checks task status and routes to either the next step or a retry/escalation path.
3. RPA Bot Error Propagation:
Implement a heartbeat mechanism in your RPA connector configuration:
- Set bot execution timeout to realistic value (e.g., 300 seconds)
- Configure the connector to return explicit failure status on timeout
- Add a scheduled event that runs every 2 minutes checking for tasks in ‘In Progress’ state longer than expected duration
Scheduled event microflow:
RETRIEVE WorkflowTask WHERE Status='InProgress'
AND StartTime < [%CurrentDateTime%] - 300 seconds
FOR EACH $StalledTask
CALL WorkflowCommons.SetTaskStatus($StalledTask, 'Failed')
CALL NotificationService.SendAlert('Task timeout', $StalledTask)
END
Additional Configuration:
In your RPA connector settings, enable ‘Propagate Exceptions’ and set ‘Return Detailed Error Info’ to true. This ensures error context from the bot is passed back to Mendix properly.
Create a configuration entity to store expected duration per bot type, allowing your timeout detection to be intelligent about what constitutes a ‘stuck’ task versus a legitimately long-running operation.
This approach handles all three failure scenarios: bot returns error, bot times out, and bot crashes without response. The workflow will always transition to a recoverable state, preventing orphaned tasks.