SuiteFlow Trigger Execution Model
When a record enters a state in a workflow, the workflow runs actions and transitions in this 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.
-
If applicable, transitions for the trigger on which the record entered the state are evaluated and executed.
-
If the record transitions to another state, actions with a trigger of Exit execute before the record transitions to the next state.
The table below shows the general order of trigger execution for actions and transitions, depending on what the user does and which trigger brought the record into the state.
Record Action |
Trigger |
Actions |
Transitions* |
---|---|---|---|
User creates or opens a record. |
Before Record Load |
|
|
Record loads into the browser. |
Any client trigger |
If applicable, actions set to a client trigger execute. |
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 their 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.
But 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 don't execute. For more information, see Initiating or Entry Trigger Rules.
Initiating or Entry Trigger Rules
To understand the SuiteFlow trigger execution model, you need to know which trigger initiates the workflow and which trigger brings a record into 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, if a workflow executes actions in a state for the Before Record Submit trigger and then moves to another state, the next state is entered on Before Record Submit. Any actions or transitions in that state set to Before Record Load won’t execute.
You can view these triggers and their order of execution in the Workflow Execution Log.
Workflow Trigger Execution Example
Let’s say you create a workflow to make a sales order field required, validate its value, and then send an email to the user’s supervisor after saving. You set the workflow to execute when a sales order is created and to trigger on Before Record Load.
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.
-
Don't 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.