08

Executing in Different Contexts

CSV Import, Scripts, Suitelets & Mass Updates

🎯 Learning Objectives

Upon completion of this module, you will be able to:

Understanding Execution Context

Workflow execution context refers to the NetSuite function or feature used to create, view, or update a record. Records can be accessed through:

📋 Why Use Contexts?

Configuring workflow execution in specific contexts allows you to restrict certain record processing to select contexts only. For example, run a workflow only during CSV imports but not through the UI.

CSV Import Context

Importing large numbers of records via CSV is common. You may want to initiate workflows only on records created via CSV import.

Configuration Requirements

  1. Enable RUN SERVER SUITESCRIPT AND TRIGGER WORKFLOWS setting
  2. Select CSV IMPORT from the CONTEXTS multi-select field on workflow definition

Two-Level Settings

Setting Location Scope Recommendation
CSV Import Global Preferences All imports Keep DISABLED
CSV Import Assistant Per import Enable when needed

✅ Best Practice

Disable the global CSV Import preference and enable the setting per import basis in the CSV Import Assistant. This prevents unintended workflow execution during routine imports.

User Event Script Context

User Event Scripts can create or update records programmatically. To trigger workflows only when records are modified by User Event Scripts:

  1. Select USER EVENT from the CONTEXTS field
  2. Ensure your User Event Script submits records (triggers Before/After Record Submit)

⚠️ Important

User Event Scripts must actually submit the record (using record.save() or similar) to trigger workflow events. Simply loading a record won't trigger workflows.

Suitelet Context

Suitelets provide on-demand processing capabilities. Use the Suitelet context when you want workflows to execute only when records are created/modified through custom Suitelet interfaces.

Use Cases

Workflow Mass Updates

Workflow mass updates allow you to process multiple records simultaneously with running workflow instances.

Mass Update Types

Mass Update Type Purpose
Trigger Workflow on Records Force workflow to trigger on selected records
Update Workflow State Move records to a specific workflow state
Reinitialize Workflow on Records Restart workflow from beginning on selected records

Example: Force Approval

Use "Update Workflow State" mass update to move multiple pending records directly to an Approved state, bypassing normal approval flow.

💡 Navigation

Access workflow mass updates via: Lists → Mass Update → Mass Updates, then look for Workflow-related options under the record type you want to process.

Context Configuration Summary

Context Use When Configuration
CSV Import Bulk data imports need workflow processing Enable in Import Assistant + select context
User Event Script-based record modifications Select context on workflow definition
Suitelet Custom interface processing Select context on workflow definition
UI (default) Standard user interactions Default behavior when no context specified

🌟 Key Takeaways