Hi @GFlo_ADB,
I’ve implemented several NetSuite-HubSpot integrations with line item syncing, and you’ve hit the classic pain point that breaks most custom scripts after initial setup. The issue isn’t your script quality—it’s the architectural mismatch between how these systems handle line items.
Why Line Item Updates Fail
1. No Stable External ID System - HubSpot line items don’t have a reliable external ID field that persists across updates. When you modify a line item, there’s no guaranteed way to match it back to the NetSuite opportunity line without custom tracking.
2. Different Data Models:
- HubSpot: Line items are independent objects associated to deals via hs_object_id
- NetSuite: Opportunity line items are child records tightly coupled to the parent with pricing rules and tax calculations
3. Update vs. Replace Behavior - NetSuite’s SuiteScript often treats line item updates as delete-and-recreate operations, while HubSpot updates in place.
Practical Solutions
Option 1: Establish a System of Record (Recommended)
Choose ONE direction for line item changes:
NetSuite as Source:
- Make HubSpot line items read-only
- All pricing/quantity changes happen in NetSuite
- Script only pulls updates from NetSuite to HubSpot
- Add a custom property to store NetSuite line item internal ID
HubSpot as Source:
- Sales team edits in HubSpot only
- Script pushes to NetSuite and overwrites
- NetSuite becomes reporting/billing destination
Option 2: Implement Line-Level External ID Tracking
Add custom fields to both systems:
- HubSpot: Create “netsuite_line_id” property on line items
- NetSuite: Add field to store HubSpot hs_object_id
On sync, match by external ID, not product name or position.
Option 3: Use HubSpot’s v4 Associations API
GET /crm/v4/objects/deals/{dealId}/associations/line_items
This returns all line items with IDs, allowing you to build a mapping table and track changes.
Common Script Issues to Check
1. Are you comparing line items by array position? (Breaks when reordered)
2. Are you handling deletions?
3. Are you using PATCH instead of PUT? (PUT replaces all items)
4. Are you respecting NetSuite’s concurrency limits? (Max 1 update/second for Opportunity records)
My Recommendation: Start with Option 1 (single source of truth). Bidirectional line item sync is complex and fragile. If you need it, Option 2 with external ID tracking is most reliable.
What platform is your custom script built on? That will help me provide more specific guidance.