πŸ“‹ Appendix E: Workflow Examples

Complete Visual Blueprints for Building Advanced Workflows

Examples Index

Example 1: SLA Reminder System

πŸ“š Module 2 ⏰ Scheduled Actions πŸ”„ Auto-Transitions

Purpose

Automatically sends reminder emails when a record has been waiting for approval too long, then auto-rejects if no action is taken within the SLA window.

Workflow Blueprint

βš™οΈ Workflow Definition
Record: Performance Review
Event: Before Record Load
Trigger: On Create
Release Status: Released
State 1: Waiting for Approval
Waiting
πŸ“§ Send Email (Reminder 1)
Trigger: Scheduled
Delay: 2 | Unit: Days | Recurrence: 0
To: {Approver}
Subject: "Approval Reminder - Action Required"
πŸ“§ Send Email (Final Warning)
Trigger: Scheduled
Delay: 4 | Unit: Days | Recurrence: 0
To: {Approver}
Subject: "URGENT: Approval Required Within 24 Hours"
β†ͺ️ Auto-Reject Transition
Transition On: Scheduled
Delay: 5 | Unit: Days
Target State: Rejected
State 3: Rejected
Exit
πŸ“ Set Field Value
Field: Approval Status
Value: Rejected
SettingValueWhy
Delay (Reminder 1)2 DaysFirst nudge after 48 hours
Delay (Final Warning)4 DaysEscalation before auto-reject
Delay (Auto-Reject)5 DaysSLA deadline enforcement
Recurrence0One-time execution per action

πŸ’‘ Key Insight

Scheduled transitions use the Scheduled trigger type, NOT a server trigger + delay. The workflow scheduler (runs every 30 min) evaluates and executes these automatically.

Example 2: Subscribe to Related Record

πŸ“š Module 5 πŸ”— Related Records πŸ‘οΈ Subscribe Action

Purpose

A Customer workflow creates a Task record and then waits. When the Task is marked complete, the Customer workflow automatically transitions to the next state.

Workflow Blueprint

βš™οΈ Workflow Definition
Record: Customer
Event: After Record Submit
Trigger: On Create
State 0: Entry State
Entry
πŸ“‹ Create Record (Task)
Record Type: Task
Title: "Follow up with new customer"
Assigned To: {Sales Rep}
Store Result In: custentity_created_task
πŸ‘οΈ Subscribe to Record
Field to Monitor: Create Record Result
Select: [Task created above]
β†ͺ️ Transition to Next State
Transition On: (blank)
Condition: Task.Status = Completed
State 1: Task Completed
πŸ“§ Send Email
To: {Sales Manager}
Subject: "Customer follow-up complete"
ComponentConfiguration
Custom Fieldcustentity_created_task (Integer) on Customer record
Create RecordStore Result In β†’ custentity_created_task
Subscribe to RecordMonitor: Create Record Result
Transition ConditionJoined field: Task.Status = Completed

πŸ’‘ Key Insight

The TRANSITION ON field must be blank when using Subscribe to Record. The transition fires when the subscription condition evaluates true, not on a trigger event.

Example 3: SQL Formula Calculations

πŸ“š Module 6 πŸ”’ SQL Formulas βš™οΈ Server Triggers

Purpose

Use SQL formulas for calculations, concatenations, and conditional logic in workflow actions and conditions on server triggers.

Formula Examples

Salary Increase (5%)
{custrecord_salary} * 1.05

Multiplies current salary by 1.05

Field Concatenation
{city} || ', ' || {state} || ' ' || {zipcode}

Result: "Austin, TX 78701"

Extract Email Domain
SUBSTR({email}, INSTR({email}, '@') + 1)

Extracts "company.com" from email

Null Handling
NVL({discount}, 0)

Returns 0 if discount is null

CASE WHEN Conditional Logic
CASE WHEN {amount} > 10000 THEN 'High' WHEN {amount} > 5000 THEN 'Medium' ELSE 'Low' END
FunctionPurposeExample
||Concatenate strings{first} || ' ' || {last}
SUBSTR()Extract substringSUBSTR({phone}, 1, 3)
INSTR()Find positionINSTR({email}, '@')
NVL()Handle nullsNVL({discount}, 0)
UPPER() / LOWER()Change caseUPPER({name})
LENGTH()String lengthLENGTH({phone}) > 10
TO_CHAR()Format number/dateTO_CHAR({amount}, '999,999')
CASE WHENConditional logicCASE WHEN {x}='A' THEN 'Yes' END

πŸ’‘ Key Insight

SQL formulas only work on server triggers (Before/After Record Submit, Before Record Load). For client triggers, use SuiteScript 1.0 formulas with nlapiGetFieldValue() instead. Mismatched formula/trigger types show "ERROR: Invalid expression" in logs.

Example 4: Workflow Action Script

πŸ“š Module 7 πŸ’» SuiteScript 2.x πŸ”§ Custom Action

Purpose

Extend SuiteFlow with custom SuiteScript logic when built-in actions don't meet requirements. Returns a value the workflow can use for subsequent decisions.

/** * @NApiVersion 2.x * @NScriptType WorkflowActionScript */ define(['N/record', 'N/log'], function(record, log) { function onAction(scriptContext) { var newRecord = scriptContext.newRecord; var workflowId = scriptContext.workflowId; // Get field value from record var amount = newRecord.getValue({ fieldId: 'amount' }); // Custom business logic var result = 'STANDARD'; if (amount > 50000) { result = 'EXECUTIVE_APPROVAL'; } else if (amount > 10000) { result = 'MANAGER_APPROVAL'; } log.debug('Approval Level', result); // Return value to workflow return result; } return { onAction: onAction }; });

Deployment Steps

1. Upload Script

File Cabinet β†’ SuiteScripts

β†’
2. Create Record

Script Type: Workflow Action

β†’
3. Deploy

Status: Released

β†’
4. Add to Workflow

Custom Action β†’ Select

Context PropertyDescription
scriptContext.newRecordThe record being processed
scriptContext.oldRecordPrevious record version (on edit)
scriptContext.workflowIdInternal ID of the workflow
scriptContext.typeEvent type (create, edit, etc.)
return valuePassed back to workflow for conditions

πŸ’‘ Key Insight

Workflows wait synchronously for scripts to complete. For long-running operations, initiate a Scheduled Script instead to process asynchronously and return control to the user immediately.

Example 5: CSV Import Context Workflow

πŸ“š Module 8 πŸ“₯ CSV Import 🎯 Context Restriction

Purpose

Execute a workflow ONLY when records are imported via CSV, not when created through the UI. Useful for tagging imported records or applying import-specific processing.

Workflow Blueprint

βš™οΈ Workflow Definition
Record: Customer
Event: On Create
Trigger: All
Context: CSV Import
State 0: Tag Imported Record
Entry/Exit
πŸ“ Set Field Value
Field: Comments
Value: "Created via CSV Import"

CSV Import Setup

Global Preferences

❌ Uncheck "Run Server SuiteScript and Trigger Workflows"

β†’
Import Assistant

βœ… Check "Run Server SuiteScript and Trigger Workflows"

β†’
Result

Workflow runs only for this import

SettingLocationValue
Global PreferenceSetup β†’ Import/Export β†’ CSV Import PreferencesDisabled
Per-Import OverrideImport Assistant β†’ Advanced OptionsEnabled
Workflow ContextWorkflow Definition β†’ ContextsCSV Import

πŸ’‘ Key Insight

The Context field acts as a filter. Even with "All" trigger type, the workflow only fires when the record is created in the specified context. Records created via UI will NOT trigger this workflow.

Example 6: Rejection Processing (UES Context)

πŸ“š Module 8 ⚑ User Event Script Context πŸ”— Workflow Chaining

Purpose

A secondary workflow triggers when ANOTHER workflow sets a field value. Creates a task for the supervisor and notifies the employee when their review is rejected.

Workflow Chain Visualization

Approval Workflow

Set Field: Status = Rejected

β†’
Rejection Processing

Triggers on UES Context

β†’
Create Task + Email

Notify supervisor & employee

Rejection Processing Workflow

βš™οΈ Workflow Definition
Record: Performance Review
Event: On View or Update
Trigger: After Record Submit
Context: User Event Script
Release Status: Released
Initiation Condition: Approval Status = Rejected
State 0: Process Rejections
Entry
πŸ“‹ Create Record (Task)
Record Type: Task
Title: "Subordinate review rejected"
Assigned To: {Subordinate.Supervisor}
Due Date: 30 days from now
Message: "Please reach out to discuss resolution"
πŸ“§ Send Email
From: Current User
To: {Subordinate}
Subject: "Your review was rejected"
Body: "Your manager will contact you"
RequirementSetting
Execute As Adminβœ… Must be enabled for UES context
Release StatusReleased (required for UES context)
Initiation ConditionApproval Status = Rejected
ContextUser Event Script

πŸ’‘ Key Insight

The "User Event Script" context means the workflow triggers when ANOTHER script or workflow modifies the recordβ€”not from user UI actions. This enables workflow chaining where one workflow's Set Field Value action triggers another workflow.

Example 7: Suitelet Integration

πŸ“š Module 8 πŸ–₯️ Suitelet Context πŸ”§ workflow.initiate() & workflow.trigger()

Purpose

Build custom NetSuite pages that interact with workflows programmatically. Process bulk approvals or initiate workflows on-demand without opening individual records.

Two API Functions

workflow.initiate()

Starts a NEW workflow instance on a record (like Initiate Workflow action)

workflow.initiate({ recordType: 'customrecord_perf_review', recordId: 123, workflowId: 'customworkflow_ondemand' });

Use case: Apply 5% bonus to eligible records

workflow.trigger()

Wakes up an EXISTING workflow and simulates a button click

workflow.trigger({ recordType: 'customrecord_perf_review', recordId: 123, workflowId: 'customworkflow_approval', actionId: 'custworkflow_approve_btn' });

Use case: Bulk approve records waiting in State 1

Process Performance Reviews Suitelet

Custom UI

Action dropdown + Multi-selects

β†’
Saved Searches

Eligible for Bonus / Outstanding Approvals

β†’
Action 1

workflow.initiate() - 5% Bonus

β†’
Action 2

workflow.trigger() - Approve

ComponentConfiguration
Suitelet Script@NScriptType Suitelet, onRequest function
Script ParametersRecord Type, Workflow ID, Button ID (configurable)
Deployment LinkSetup β†’ Custom β†’ [Menu Name]
Saved Search 1Performance Reviews with Rating Code = A
Saved Search 2Reviews in State 1 with Approve Button visible

πŸ’‘ Key Insight

workflow.initiate() = Start fresh workflow. workflow.trigger() = Wake up existing workflow + click button. In the execution log, you'll see "Workflow triggered to process transition by click on button [name]".

Example 8: Mass Update Patterns

πŸ“š Module 8 πŸ“¦ Batch Processing 4 Update Types

Purpose

Process multiple records with running workflow instances simultaneously. Initiate, process, cancel, or force-transition workflows in bulk based on saved search criteria.

Four Mass Update Types

INITIATE
Start

Start workflow on multiple records without opening each one

Use case: After CSV import, initiate approval workflow on all imported records

PROCESS
Execute

Re-evaluate transitions or simulate button click

Use case: Bulk approve all records waiting in "Pending Approval" state

CANCEL
Admin Only

Cancel running workflow instances

Use case: Cancel obsolete workflows after process change

TRANSITION
Force

Force transition to ANY state (bypass normal path)

Use case: Move accidentally rejected records back to approval state

Navigation Path

Lists β†’ Mass Update β†’ Mass Updates β†’ Workflows β†’ [Record Type] β†’ [Workflow Name]

Define Criteria

Same as saved search

β†’
Name Update

Creates saved mass update

β†’
Schedule (Optional)

Run during off-peak hours

β†’
Execute

Process matching records

Update TypeWhen to UsePermission
InitiateStart workflow on records without opening each oneStandard
ProcessSimulate button click or re-evaluate transitionsStandard
CancelStop workflows that are stuck or no longer neededAdmin Only
TransitionFix records in wrong state or stuck workflowsStandard

πŸ’‘ Key Insight

Process vs Transition: Process follows the normal workflow path (next state). Transition can jump to ANY state, even backwards. Use Transition for error recovery; use Process for bulk automation.

← Back to Course Overview