Terminates the execution of the current event flow; subsequent steps will not run. It is commonly used when business conditions are not met, the user cancels, or an irrecoverable error occurs.
ctx.exit() is generally used in the following contexts where JS can be executed:
| Scenario | Description |
|---|---|
| Event Flow | In event flows triggered by form submissions, button clicks, etc., terminates subsequent steps when conditions are not met. |
| Linkage Rules | In field linkages, filter linkages, etc., terminates the current event flow when validation fails or execution needs to be skipped. |
| Action Events | In custom actions (e.g., delete confirmation, pre-save validation), exits when the user cancels or validation fails. |
Difference from
ctx.exitAll():ctx.exit()only terminates the current event flow; other event flows under the same event are not affected.ctx.exitAll()terminates the current event flow as well as any subsequent event flows under the same event that have not yet been executed.
Calling ctx.exit() throws an internal FlowExitException, which is caught by the FlowEngine to stop the current event flow execution. Once called, the remaining statements in the current JS code will not execute.
| Method | Scope of Effect |
|---|---|
ctx.exit() | Terminates only the current event flow; subsequent event flows are unaffected. |
ctx.exitAll() | Terminates the current event flow and aborts subsequent event flows under the same event that are set to execute sequentially. |
ctx.exit(), subsequent code in the current JS will not execute; it is recommended to explain the reason to the user via ctx.message, ctx.notification, or a modal before calling it.FlowExitException in business code; let the FlowEngine handle it.ctx.exitAll().