Integration Patterns
Every integration falls into one of these patterns. Find yours, understand when to use it, and get the code.
The Pattern Matrix
NETSUITE INTEGRATION PATTERNS
─────────────────────────────────────────────────────────────────
NETSUITE'S ROLE
┌──────────────────┬──────────────────┐
│ ACTIVE │ PASSIVE │
│ (Initiates) │ (Responds) │
──────────────┼──────────────────┼──────────────────┤
│ │ │
OUTBOUND │ Pattern 1: │ Pattern 4: │
(Data OUT) │ PUSH OUT │ EXPOSE DATA │
│ NS → External │ External → NS │
│ │ (queries) │
──────────────┼──────────────────┼──────────────────┤
│ │ │
INBOUND │ Pattern 2: │ Pattern 3: │
(Data IN) │ PULL IN │ RECEIVE DATA │
│ NS ← External │ External → NS │
│ (fetches) │ (pushes) │
│ │ │
└──────────────────┴──────────────────┘
All Patterns at a Glance
| Pattern | Description | NetSuite Role | Script Types |
|---|---|---|---|
| Push Out | NetSuite sends data to external systems | Active | User Event, Workflow Action, Scheduled, Map/Reduce |
| Pull In | NetSuite fetches data from external systems | Active | Scheduled, Map/Reduce, Suitelet |
| Receive | External systems send data to NetSuite | Passive | RESTlet, Suitelet |
| Expose | External systems query NetSuite for data | Passive | RESTlet, SuiteTalk |
| File-Based | Exchange data via SFTP files | Active | Scheduled, Map/Reduce |
| Middleware | Use middleware for complex integrations | N/A | Any |
Quick Reference: Which Script for Which Pattern?
| Pattern | Script Type | Timing | Use Case |
|---|---|---|---|
| Push Out (Real-time) | User Event Script | afterSubmit | Sync on save |
| Push Out (Workflow) | Workflow Action Script | Workflow trigger | Conditional sync |
| Push Out (Batch) | Scheduled/Map-Reduce | Periodic | Bulk export |
| Pull In (Periodic) | Scheduled Script | Every X minutes | Polling external API |
| Pull In (Bulk) | Map/Reduce Script | Periodic | High-volume import |
| Receive (Authenticated) | RESTlet | On-demand | Webhook with auth |
| Receive (Public) | Suitelet | On-demand | Webhook without auth |
| Expose Data | RESTlet / SuiteTalk | On-demand | External queries NS |
Decision Flowchart
CHOOSING THE RIGHT PATTERN
─────────────────────────────────────────────────────────────────
Who initiates the data transfer?
│
├── NetSuite (Active)
│ │
│ ├── Data going OUT?
│ │ │
│ │ ├── Real-time? ──────▶ User Event Script
│ │ ├── Conditional? ────▶ Workflow Action Script
│ │ ├── Periodic? ───────▶ Scheduled Script
│ │ └── Bulk? ───────────▶ Map/Reduce Script
│ │
│ └── Data coming IN?
│ │
│ ├── Periodic fetch? ──▶ Scheduled Script
│ ├── High volume? ─────▶ Map/Reduce Script
│ └── On-demand? ───────▶ Suitelet (button)
│
└── External System (Passive)
│
├── Sending data TO NetSuite?
│ │
│ ├── Can do OAuth? ────▶ RESTlet
│ ├── No OAuth? ────────▶ Suitelet (public)
│ └── High volume? ─────▶ RESTlet + Queue + M/R
│
└── Querying data FROM NetSuite?
│
├── Custom logic? ────▶ RESTlet
├── Standard CRUD? ───▶ SuiteTalk REST
└── Legacy system? ───▶ SuiteTalk SOAP
Quick Reference: N/https Methods
| Method | Use Case |
|---|---|
https.get() | Fetch data from external API |
https.post() | Send data to external API |
https.put() | Update data in external API |
https.delete() | Delete data in external API |
https.request() | Custom HTTP method |
https.get.promise() | Async GET (non-blocking) |
https.post.promise() | Async POST (non-blocking) |
https.requestRestlet() | Call another NetSuite RESTlet |
https.requestSuiteTalkRest() | Call SuiteTalk REST API |
Best Practices Summary
| Practice | Why |
|---|---|
Use https.post.promise() for outbound | Don't block user transactions |
| Implement retry queue | External systems fail |
| Validate webhook signatures | Security |
| Log all API calls | Debugging & audit |
| Set timeouts | Don't hang on slow APIs |
| Use Map/Reduce for bulk | Governance limits |
| Store API keys in script parameters | Don't hardcode secrets |
| Return fast from RESTlets | Queue heavy processing |
Related Documentation
- OAuth 1.0 (TBA) Setup - Token-Based Authentication
- OAuth 2.0 Setup - Modern OAuth with certificates
- SuiteQL Reference - Query language for APIs