Introduction
Modern businesses rarely operate in isolation. Your CRM, eCommerce, and marketing systems all need to share data with NetSuite in real-time.
Whether youβre syncing customer records, sales orders, or inventory β building seamless integrations between systems like Salesforce, Shopify, and HubSpot can dramatically improve efficiency.
This guide explains how NetSuite connects via RESTlets and SuiteTalk, complete with examples, authentication tips, and mapping strategies.
π§ 1. Integration Methods Overview
Integration Type | Tool | Use Case | Authentication |
---|---|---|---|
RESTlet (SuiteScript) | Custom REST API endpoint | Real-time integration, flexibility | Token-Based Auth |
SuiteTalk (SOAP/REST) | Built-in NetSuite Web Services | Large record operations, third-party integrations | Token-Based / OAuth |
Third-Party Middleware | Boomi, Celigo, MuleSoft | Drag-and-drop integrations | Token or Basic Auth |
π 2. Setting Up Token-Based Authentication (TBA)
Before any API integration, enable TBA:
- Navigate to Setup β Company β Enable Features β SuiteCloud β Manage Authentication.
- Enable Token-Based Authentication.
- Create an Integration Record.
- Generate Consumer Key / Secret and Token ID / Secret.
Youβll use these to authenticate external API calls.
π 3. Example 1: Salesforce β NetSuite (Customer Sync via RESTlet)
Goal: Create or update NetSuite Customer when a new Lead converts in Salesforce.
A. SuiteScript RESTlet (in NetSuite)
/**
* @NApiVersion 2.1
* @NScriptType Restlet
*/
define(['N/record', 'N/log'], (record, log) => {
const post = (data) => {
try {
const rec = record.create({ type: record.Type.CUSTOMER });
rec.setValue('companyname', data.companyName);
rec.setValue('email', data.email);
rec.setValue('phone', data.phone);
const id = rec.save();
return { success: true, id };
} catch (e) {
log.error('Error creating customer', e);
return { success: false, message: e.message };
}
};
return { post };
});
B. Salesforce Callout (Apex Example)
HttpRequest req = new HttpRequest();
req.setEndpoint('https://ACCOUNTID.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=123&deploy=1');
req.setMethod('POST');
req.setHeader('Authorization', 'NLAuth nlauth_account=XXXX, nlauth_consumer_key=XXXX, nlauth_token=XXXX');
req.setHeader('Content-Type', 'application/json');
req.setBody(JSON.serialize(new Map<String, Object>{
'companyName' => 'TechNova',
'email' => 'contact@technova.com',
'phone' => '1234567890'
}));
Http h = new Http();
HttpResponse res = h.send(req);
System.debug(res.getBody());
β Result: Each new Salesforce Lead creates a Customer in NetSuite.
ποΈ 4. Example 2: Shopify β NetSuite (Sales Order Integration)
Goal: Import new Shopify orders automatically into NetSuite.
A. Shopify Webhook β Middleware (Boomi / Custom Script) β RESTlet
Webhook payload example:
{
"order_number": 3001,
"email": "buyer@example.com",
"total_price": "149.99",
"line_items": [
{"title": "Toy Car", "quantity": 2, "price": "29.99"}
]
}
B. RESTlet to Create Sales Order
define(['N/record', 'N/log'], (record, log) => ({
post: (order) => {
try {
const so = record.create({ type: record.Type.SALES_ORDER });
so.setValue('entity', order.customerId);
order.line_items.forEach(item => {
const line = so.selectNewLine({ sublistId: 'item' });
line.setValue('item', item.itemId);
line.setValue('quantity', item.quantity);
line.commitLine('item');
});
const id = so.save();
return { success: true, orderId: id };
} catch (e) {
log.error('Error creating SO', e);
return { success: false, message: e.message };
}
}
}));
β Result: Orders flow directly from Shopify to NetSuite in real-time.
π¬ 5. Example 3: HubSpot β NetSuite (Contact Integration)
Goal: Sync HubSpot contacts into NetSuite for marketing and CRM consistency.
RESTlet Example
define(['N/record'], (record) => ({
post: (data) => {
const contact = record.create({ type: record.Type.CONTACT });
contact.setValue('firstname', data.firstName);
contact.setValue('lastname', data.lastName);
contact.setValue('email', data.email);
contact.save();
return { success: true };
}
}));
HubSpot can post data to this endpoint through a webhook or Zapier connector.
β Result: New HubSpot contacts appear in NetSuite instantly.
π 6. Mapping Example β Shopify to NetSuite
Shopify Field | NetSuite Field | Data Type | Example |
---|---|---|---|
order_number | tranid | Text | 10025 |
entity.email | buyer@example.com | ||
line_items[].title | item.displayname | Text | Hoodie |
line_items[].quantity | item.quantity | Number | 2 |
total_price | total | Currency | 149.99 |
β Best Practice: Maintain mapping tables in custom records for flexibility.
βοΈ 7. Error Handling in Integrations
- Log all responses using
log.error()
or custom integration logs. - Implement retry logic in middleware for failed transactions.
- Use status tracking fields like
custbody_integration_status
.
π 8. Security & Performance Tips
- Use TBA instead of NLAuth for integrations.
- Paginate API responses for large data sets.
- Avoid record loads in loops.
- Cache configuration data (like item mappings) in memory.
- Implement
governance checks
in long-running RESTlets.
π§ 9. When to Use Middleware (Celigo / Boomi / MuleSoft)
If your integration requires:
- Complex transformation logic
- High-volume batch processing
- Error queues and dashboards
β¦then using middleware is more efficient than direct RESTlets.
β 10. Testing Checklist
Area | Check |
---|---|
Authentication | TBA or OAuth validated |
Field Mapping | Source/target match verified |
Error Handling | Retries and logs in place |
Data Volume | Large batch tested |
Sync Direction | One-way or two-way clearly defined |
Conclusion
NetSuite API integrations unlock automation across your business ecosystem.
Whether connecting to Salesforce, Shopify, or HubSpot, the approach remains the same:
- Secure authentication
- Clear mapping
- Reliable error handling
By mastering RESTlets and SuiteTalk, you can connect NetSuite with virtually any platform β enabling a unified, automated, data-driven business.
Discover more from The NetSuite Pro
Subscribe to get the latest posts sent to your email.
Leave a Reply