HubSpot to Business Central - Deals to Sales Orders Integration Guide

Overview

This guide documents the integration setup for syncing HubSpot Deals to Business Central Sales Orders using Rapidi. The integration supports two scenarios based on HubSpot edition capabilities.

Integration Architecture

Scenario 1: Enterprise Edition (with Operations Hub)

Prerequisites:

  • HubSpot Enterprise or Professional edition with Operations Hub.
  • Custom workflow capability in HubSpot ( provided by Rapidi).

HubSpot Custom Fields Required:

Field NameObjectTypePurpose
bc_salesorderDealTextStores BC Sales Order Number
erp_customer_noDealProperty SyncSyncs BC Customer Number from Company
associated_deal_idLine ItemTextPopulated by custom workflow
erp_sales_order_noLine ItemProperty SyncStores BC Order Number on lines

Custom Workflow Configuration

Purpose: Automatically populate associated_deal_id on line items with the parent Deal ID.

Workflow Setup:

  1. Trigger: Line Item creation or Deal association.
  2. Action: Copy Deal's hs_object_id to Line Item's associated_deal_id.
  3. Scope: All line items associated with deals.

Rapidi Setup Summary

Transfer Structure:

  • Main Transfer: DEAL00_HUBSPOT_BC_SUBTR (Deals → Sales Orders)
  • SubTransfer: DEAL00_HUBSPOT_BC_SUBTR_SUBTR001 (Line Items → Sales Order Lines)

Detailed Flow:

  1. Main Transfer Executes:
    • Queries HubSpot for Deals where bc_salesorder is empty (new/unsynced deals).
    • Pulls Deal data: deal name, close date, currency, customer number,etc.
    • Creates Sales Order in Business Central or other D365 ERP.
    • The ERP returns the new Sales Order Number (e.g., SO-10001)
  2. Rapidi Writes Back to HubSpot:
    • Stores the BC Sales Order Number in the Deal's bc_salesorder field.
  3. SubTransfer Auto-Executes (Same Transaction):
    • Triggered automatically for the same deal that was just processed.
    • Uses LinkFilter: pulls Line Items where associated_deal_id = Deal's hs_object_id.
    • This field was pre-populated by the custom HubSpot workflow.
    • Pulls Line Item data: SKU, quantity, price.
    • Creates Sales Order Lines in BC linked to the parent Sales Order.
  4. Result:
    • Complete Sales Order (header + lines) created in BC in one operation.
    • Deal marked as synced via bc_salesorder field.

Scenario 2: Standard Edition (without Operations Hub)

Prerequisites:

  • HubSpot Professional/Starter edition (no Operations Hub).
  • Cannot use custom workflows.

HubSpot Custom Fields Required:

Field NameObjectTypePurpose
bc_salesorderDealTextStores ERP Sales Order Number
erp_customer_noDealProperty SyncSyncs ERP Customer Number from Company
erp_sales_order_noLine ItemTextIt automatically stores the ERP Order Number
transferred_to_erpLine ItemTextTransfer control flag

Rapidi Setup Summary

Transfer Structure:

  • Transfer 1: DEAL01_HUBSPOT_BC (Deals → Sales Orders)
  • Transfer 2: DEAL02_HUBSPOT_BC (Line Items → Sales Order Lines)

Detailed Flow:

Phase 1: Header Creation

  1. Transfer DEAL01 Executes:
    • Queries HubSpot for Deals where bc_salesorder is empty (new/unsynced deals).
    • Pulls Deal data: deal name, close date, currency, customer number.
    • Creates Sales Order header in the ERP.
    • BC returns the new Sales Order Number (e.g., SO-10001).
  2. Rapidi Writes Back to HubSpot:
    • Stores the BC Sales Order Number in the Deal's bc_salesorder field.
  3. HubSpot Property Sync Activates:
    • Property sync field erp_sales_order_no on Line Items monitors the parent Deal.
    • When Deal's bc_salesorder field gets populated, it syncs down to all associated Line Items.
    • Each Line Item now has erp_sales_order_no = "SO-10001".

Phase 2: Line Creation

  1. Transfer DEAL02 Executes:
    • Queries HubSpot for Line Items where:
      • erp_sales_order_no HAS_PROPERTY (must be populated).
      • transferred_to_erp is empty (not yet synced).
  2. Pulls Line Item data: SKU, quantity, price, and the erp_sales_order_no.
  3. Creates Sales Order Lines in BC.
  4. Uses erp_sales_order_no to match and link lines to the correct Sales Order header.
  5. Rapidi Marks Lines as Transferred:
    • Updates Line Items in HubSpot with transferred_to_erp flag.
    • Prevents duplicate line creation on subsequent runs.
  6. Result:
    • Sales Order header exists from Phase 1.
    • Sales Order lines now added and linked correctly.
    • Both Deal and Line Items marked as synced.