ExecuteWorkflowEvent

You can use the ExecuteWorkflowEvent function to automate workflow event execution, such as Approve, Reject, or Complete, from scripts without manual user interaction. The function enables one workflow to trigger an event on another workflow programmatically and enables automated workflow progression.

When to use

You can use this function to:

  • Automatically approve or complete workflow steps based on system validation or business rules without manual intervention.
  • Coordinate multiple workflows by allowing one workflow to trigger events on another workflow programmatically.

When not to use

You cannot use this function when the action requires comments, confirmations, signatures, or reasons, as these require manual user input.

Syntax

int ExecuteWorkflowEvent(int wipId, int wipLineId, string eventCode);

Return Value

The application returns a value greater than zero (0) if the operation is successful.

Parameters

Parameter Type Required Description
wipId Numeric Yes The WIP ID of the workflow.
wipLineId Numeric Yes The Line ID for the action step in the Workflow-in-Progress form that has Queue Status of 1 (In Process Queue).
eventCode string Yes The name of the event to execute. For example, "Approve", "Reject", "Complete"). The events cannot have the comment, confirm, sign, or reason options enabled.

Prerequisites

  • No special user permissions are required.
  • The function cannot bypass requirements for user interaction, comments, confirmations, signatures, or reasons.

Examples

Example 1
Workflow to execute a WIP event (CANCEL).
    public long wf_start()
    {
        try
        {
            // Read inputs supplied to the workflow action (WIP input parameters)
            string sWipId = WIPParamGet("WIP_ID");
            string sWipLineId = WIPParamGet("WIPLINE_ID");

            // Execute the CANCEL event for the specified WIP line
            int rc = ExecuteWorkflowEvent(wipId, wipLineId, "CANCEL");

            MessageList($"ExecuteWorkflowEvent returned: {rc} for WIP {wipId} line {wipLineId} (Event=CANCEL)");

            // Handle common outcomes if you want (rc meanings depend on implementation)
            // Return the original example's code for success
            if (rc >= 0)
                return 111L;

            // Non-success path
            return 0L;
        }
        catch (Exception ex)
        {
            MessageList("Error executing WIP event: " + ex.Message);
            return 0L;
        }
    }
}
Description
This workflow reads WIP_ID and WIPLINE_ID from the workflow input parameters, calls ExecuteWorkflowEvent(wipId, wipLineId, "CANCEL") to process the CANCEL event on that WIP line, logs results, and returns a numeric status code (keeps the example’s RETURN 111 behavior).