SuiteFlow Trigger Execution Model
When a record in a workflow enters a state, the workflow instance executes actions and transitions in the following order:
-
Actions and transitions with an Entry trigger execute. The actions only execute the first time a record enters a state. Then the transitions execute.
-
Actions for the trigger on which the record entered the state execute.
-
Transitions for the trigger on which the record entered the state are evaluated and executed, if applicable.
-
If the record transitions to another state, actions with a trigger of Exit execute before the record transitions to the next state.
The following table describes the general order of trigger execution for actions and transitions for a state in a workflow, depending on the record action when the record is in the state and the trigger on which the record entered the state.
Record Action |
Trigger |
Actions |
Transitions* |
---|---|---|---|
User creates or opens a record. |
Before Record Load |
|
|
Record loads into the browser. |
Any client trigger |
Actions set to a client trigger execute, if applicable. |
None. Transitions do not execute on client triggers. |
User clicks Save on the record. |
Before Record Submit |
Actions set to trigger on Before Record Submit execute. |
Transitions set to trigger on Before Record Submit execute. |
After Record Submit |
Actions set to trigger on After Record Submit execute. |
Transitions set to trigger on After Record Submit execute. |
|
* Note: Transitions with no Trigger On value (blank trigger) execute as soon as the conditions are met. |
For example, if the record enters the state on the Before Record Load trigger, actions set to trigger on Entry and all the subsequent triggers may execute, depending on the state layout.
However, if the record enters the state on the Before Record Submit trigger, only actions set to trigger on Entry, Before Record Submit, and After Record Submit execute. Actions and transitions for the Before Record Load trigger and any client triggers do not execute. For more information, see Initiating or Entry Trigger Rules.
Initiating or Entry Trigger Rules
Understanding the SuiteFlow trigger execution model depends on knowing the trigger on which a workflow instance initiates and the trigger on which a record enters a state:
-
Trigger on which a workflow initiates. When a workflow initiates, it begins executing the server triggers in the following order, starting with the trigger on which the workflow initiated:
-
Before Record Load
-
Before Record Submit
-
After Record Submit
If a workflow initiates on an ALL or Before Record Load trigger, the workflow instance executes the Before Record Load trigger first, then the Before Record Submit and After Record Submit triggers after the user saves the record. If a workflow instance initiates on a Before Record Submit trigger, the Before Record Load trigger never executes.
For more information about initiating a workflow, see Workflow Initiation.
-
-
Trigger on which a workflow enters a state. The trigger on which a record enters a state depends on the server trigger that the workflow instance is currently executing.
For example, a workflow instance executes actions in a state for the Before Record Submit trigger and then transitions to another state. The current trigger being executed is Before Record Submit. Consequently, the workflow instance enters the next state on a Before Record Submit trigger. Any actions or transitions in the next state that trigger on a Before Record Load trigger do not execute.
You can view these triggers and their order of execution in the Workflow Execution Log.
Workflow Trigger Execution Example
You create a workflow to mark a sales order field as required, validate the field value, and then send an email to the user’s supervisor after the record is saved. You create a workflow that initiates on the creation of a sales order record and triggers on the Before Record Load server trigger.
The following table describes the states in the workflow:
State Name |
Description |
---|---|
State 1 Entry |
Contains an action and a transition. The action triggers on Entry and makes a field required on the record form. The transition triggers on Before Record Load and transitions to State 2. |
State 2 Field Validation |
Contains an action to validate the value of the field when the user modifies it. Contains a transition that triggers on Before Record Submit and transitions to State 3. |
State 3 Send Email |
Contains an action that triggers on After Record Submit and sends an email that notifies the user’s supervisor that the sales order was entered. |
The workflow instance executes as follows:
-
The workflow instance initiates when the user creates the sales order record and enters the entry state, State 1 Entry.
The server trigger on which the record enters the state is Before Record Load.
-
The workflow instance executes actions set to trigger on Entry and marks the field as required. Then, the workflow instance executes the Before Record Load trigger, executes the transition, and the record enters State 2 Field Validation.
-
The server trigger on which the record enters the state is still Before Record Load.
The workflow instance executes the client trigger when the user edits the required field and makes sure the field has the correct value. The user clicks Save and the Before Record Submit trigger executes and the record transitions to State 3 Send Email.
-
The record enters State 3 Send Email on the last trigger that executed, Before User Submit. The workflow instance then executes the next server trigger, which is After Record Submit. The send email action executes and the workflow completes.
Rules and Guidelines for Workflow Triggers and Trigger Execution
Use the following rules and guidelines when working with workflow triggers:
-
Make sure actions set to execute on the Entry trigger are valid for the current server trigger.
If an action executes on the Entry trigger, the action must be able to be executed on the current server trigger for the state. For example, a state contains a Send Email action set to execute on the Entry trigger and the record enters the state on the Before Record Load server trigger. However, the Before Record Load trigger is not a valid trigger type for the Send Email action. Consequently, the Send Email action does not execute.
You can see which server triggers are valid for an action by viewing the Trigger On property for the action. You can also view the help for the action. For a list of all actions, see Workflow Actions Overview.
-
Do not add actions to Exit states for any triggers other than the trigger on which the record enters the state.
Exit states are indicated in the workflow diagrammer. Exit states only execute actions associated with the trigger on which the record entered the state. For example, if a record enters the final state in a workflow on a Before Record Load trigger, actions set to execute on a Before Record Submit or a After Record Submit trigger do not execute. For more information, see Exit States.
-
If a user reloads the record when a record is in a state, NetSuite executes the server triggers again, starting with the Before Record Load trigger. Actions set to execute on Entry do not execute again.