<turbo-stream action="update" target="wiki_card"><template>

<h1>HubSpot to Business Central - Deals to Sales Orders Integration Guide</h1>
<div class="trix-content"><h2>Overview</h2><p>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.</p><h2><strong><u>Integration Architecture</u></strong></h2><h3><strong>Scenario 1: Enterprise Edition (with Operations Hub)</strong></h3><p><strong>Prerequisites:</strong></p><ul><li>HubSpot Enterprise or Professional edition with Operations Hub.</li><li>Custom workflow capability in HubSpot ( provided by Rapidi).</li></ul><h3><strong>HubSpot Custom Fields Required:</strong></h3><p></p><figure class="attachment attachment--content"><table class="table table-bordered"><thead><tr><td>Field Name</td><td>Object</td><td>Type</td><td>Purpose</td></tr></thead><tbody><tr><td>bc_salesorder</td><td>Deal</td><td>Text</td><td>Stores BC Sales Order Number</td></tr><tr><td>erp_customer_no</td><td>Deal</td><td>Property Sync</td><td>Syncs BC Customer Number from Company</td></tr><tr><td>associated_deal_id</td><td>Line Item</td><td>Text</td><td>Populated by custom workflow</td></tr><tr><td>erp_sales_order_no</td><td>Line Item</td><td>Property Sync</td><td>Stores BC Order Number on lines</td></tr></tbody></table><figcaption class="attachment__caption"></figcaption></figure><p></p><h3><strong>Custom Workflow Configuration</strong></h3><p>Purpose: Automatically populate <strong>associated_deal_id</strong> on line items with the parent Deal ID.</p><p>Workflow Setup:</p><ol><li>Trigger: Line Item creation or Deal association.</li><li>Action: Copy Deal's hs_object_id to Line Item's associated_deal_id.</li><li>Scope: All line items associated with deals.</li></ol><h3><strong>Rapidi Setup Summary</strong></h3><p><strong>Transfer Structure:</strong></p><ul><li>Main Transfer: DEAL00_HUBSPOT_BC_SUBTR (Deals → Sales Orders)</li><li>SubTransfer: DEAL00_HUBSPOT_BC_SUBTR_SUBTR001 (Line Items → Sales Order Lines)</li></ul><p>Detailed Flow:</p><ol><li><strong>Main Transfer Executes:</strong><ul><li>Queries HubSpot for Deals where bc_salesorder is empty (new/unsynced deals).</li><li>Pulls Deal data: deal name, close date, currency, customer number,etc.</li><li>Creates Sales Order in Business Central or other D365 ERP.</li><li>The ERP returns the new Sales Order Number (e.g., SO-10001)</li></ul></li><li><strong>Rapidi Writes Back to HubSpot:</strong><ul><li>Stores the BC Sales Order Number in the Deal's bc_salesorder field.</li></ul></li><li><strong>SubTransfer Auto-Executes (Same Transaction):</strong><ul><li>Triggered automatically for the same deal that was just processed.</li><li>Uses LinkFilter: pulls Line Items where associated_deal_id = Deal's hs_object_id.</li><li>This field was pre-populated by the custom HubSpot workflow.</li><li>Pulls Line Item data: SKU, quantity, price.</li><li>Creates Sales Order Lines in BC linked to the parent Sales Order.</li></ul></li><li><strong>Result</strong>:<ul><li>Complete Sales Order (header + lines) created in BC in one operation.</li><li>Deal marked as synced via bc_salesorder field.</li></ul></li></ol><h3><strong>Scenario 2: Standard Edition (without Operations Hub)</strong></h3><p><strong>Prerequisites:</strong></p><ul><li>HubSpot Professional/Starter edition (no Operations Hub).</li><li>Cannot use custom workflows.</li></ul><h3>HubSpot Custom Fields Required:</h3><p></p><figure class="attachment attachment--content"><table class="table table-bordered"><thead><tr><td>Field Name</td><td>Object</td><td>Type</td><td>Purpose</td></tr></thead><tbody><tr><td>bc_salesorder</td><td>Deal</td><td>Text</td><td>Stores ERP Sales Order Number</td></tr><tr><td>erp_customer_no</td><td>Deal</td><td>Property Sync</td><td>Syncs ERP Customer Number from Company</td></tr><tr><td>erp_sales_order_no</td><td>Line Item</td><td>Text</td><td>It automatically stores the ERP Order Number</td></tr><tr><td>transferred_to_erp</td><td>Line Item</td><td>Text</td><td>Transfer control flag</td></tr></tbody></table><figcaption class="attachment__caption"></figcaption></figure><p></p><h3>Rapidi Setup Summary</h3><p><strong>Transfer Structure:</strong></p><ul><li>Transfer 1: DEAL01_HUBSPOT_BC (Deals → Sales Orders)</li><li>Transfer 2: DEAL02_HUBSPOT_BC (Line Items → Sales Order Lines)</li></ul><p><strong>Detailed Flow:</strong></p><p><strong><u>Phase 1: Header Creation</u></strong></p><ol><li>Transfer DEAL01 Executes:<ul><li>Queries HubSpot for Deals where bc_salesorder is empty (new/unsynced deals).</li><li>Pulls Deal data: deal name, close date, currency, customer number.</li><li>Creates Sales Order header in the ERP.</li><li>BC returns the new Sales Order Number (e.g., SO-10001).</li></ul></li><li>Rapidi Writes Back to HubSpot:<ul><li>Stores the BC Sales Order Number in the Deal's bc_salesorder field.</li></ul></li><li>HubSpot Property Sync Activates:<ul><li>Property sync field erp_sales_order_no on Line Items monitors the parent Deal.</li><li>When Deal's bc_salesorder field gets populated, it syncs down to all associated Line Items.</li><li>Each Line Item now has erp_sales_order_no = "SO-10001".</li></ul></li></ol><p><strong><u>Phase 2: Line Creation</u></strong></p><ol><li>Transfer DEAL02 Executes:<ul><li>Queries HubSpot for Line Items where:<ul><li>erp_sales_order_no HAS_PROPERTY (must be populated).</li><li>transferred_to_erp is empty (not yet synced).</li></ul></li></ul></li><li>Pulls Line Item data: SKU, quantity, price, and the erp_sales_order_no.</li><li>Creates Sales Order Lines in BC.</li><li>Uses erp_sales_order_no to match and link lines to the correct Sales Order header.</li><li>Rapidi Marks Lines as Transferred:<ul><li>Updates Line Items in HubSpot with transferred_to_erp flag.</li><li>Prevents duplicate line creation on subsequent runs.</li></ul></li><li>Result:<ul><li>Sales Order header exists from Phase 1.</li><li>Sales Order lines now added and linked correctly.</li><li>Both Deal and Line Items marked as synced.</li></ul></li></ol></div>
</template></turbo-stream>

