CRM architecture & data integrity
885 orphaned deals, and the timing problem behind them
A medical spa’s HubSpot pipeline had quietly desynchronised from its point-of-sale system. Deals were reaching Appointment Scheduled with no appointment attached. The cause was not the automation logic. It was the order the events arrived in.
By Manan AsimUpdated
Key figures
Scope and diagnostic figures from the engagement
- 885orphaned deals identified
- 6+overlapping workflows competing to move the same deals
- 4×daily batch sync from the point of sale, the source of the gap
- 2defects caught in validation, before launch
Engagement
- Client
- Multi-location medical spa
- Sector
- Medical aesthetics
- Engagement
- Diagnostic + build
- My role
- Design and engineering
- Delivered
- At Growlyze Technologies
Tech stack
- HubSpot Operations Hub
- Custom-coded actions (Node.js 20)
- CRM v3 API
- CRM v4 Associations API
- Custom objects
- Private apps
Architecture
How the pieces connect
- 01 Booking
- Point of sale
- 02 Sync
- Batch sync, 4× daily
- 03 Triggers
- Appointment created
- Deal event, delayed
- Nightly sweep
- 04 Engine
- Association engine
- 05 Result
- Deal linked to appointment
- Ambiguous: flagged for review
- Source
- Step
- Logic
- Output
01 · Challenge
Deals were reaching Appointment Scheduled with no appointment attached. Six or more overlapping workflows tried to move them forward, and attribution broke wherever the link was missing.
02 · Strategy
Trace the failure to its cause, a race between a deal-side trigger and a point-of-sale sync that runs four times a day, then invert the trigger: one association engine reached by three independent paths.
03 · Impact
885 orphaned deals identified and explained. The engine is built and validated against live records, two defects were caught before launch, and the historical repair is staged behind five controls for client sign-off.
01Context
The client runs daily aesthetic appointments across several centres. HubSpot is the marketing and sales system of record. A separate point-of-sale platform owns the booking calendar, and a third-party integration pushes appointment records into HubSpot as a custom object.
A large and growing population of deals had reached Appointment Scheduled with no appointment object attached and no appointment date populated. Six or more overlapping workflows had accumulated over time, each trying to move deals forward on a slightly different signal. None of them reliably created the association itself.
Attribution flows through the deal-to-appointment link, so every orphaned record was booked revenue that could not be traced back to the campaign that produced it.
02Root cause: a race condition, not a logic error
Every workflow that tried to advance a deal was triggered by a deal-side event. When a booking is entered at the point of sale, the rep updates the contact’s lead status, which immediately fires automation and advances the deal. The appointment record only arrives in HubSpot later, on a batch cycle that runs four times a day.
So the record each workflow needed did not exist yet at the moment it ran, sometimes for hours. No amount of refinement to a deal-triggered workflow changes when it runs.
03Approach
Diagnose before building
Root-cause analysis plus an audit of the objects and properties involved: the Appointment custom object, start time, point-of-sale status and final sale price.
Invert the trigger
One association engine, reached by three independent paths. The primary path fires the moment an appointment record is created or updated. A deal-triggered backup deliberately waits before evaluating. A nightly safety net passes over deals still missing an association.
A seven-step selection rule
Restrict to the right pipeline and the two qualifying stages. Exit if the deal already carries an appointment, so existing links are never overwritten. Filter to the single open status out of nineteen. Discard appointments already serving another deal. Keep those dated today or later, nearest first. Prefer the nearest with a sale value above zero, and fall back to the nearest regardless.
When in doubt, halt
Where a contact holds more than one qualifying deal, the engine does not choose. It stops and flags the record for human review.
Validate one record at a time
The workflow stayed deactivated during testing. Records were enrolled manually, one by one, across five case types, and each run emitted a structured decision trace explaining what it did and why.
Fix what validation surfaced
Two defects were caught before launch. Appointments associated to several contacts had been resolved by trusting whichever the API returned first. And date-only values were being compared as timestamps, so timezone arithmetic pushed them back across the day boundary. Comparison moved to whole calendar days.
04Remediation controls
Repairing 885 historical records is not a code problem. It is a blast-radius problem. The historical run is wrapped in five controls.
- Dry run before any write
- Client review of the proposed changes
- A suppression flag to exclude records
- Staged rollout rather than one bulk pass
- An audit trail logging both record identifiers on every write, so the run is fully reversible
05Where it stands
| Stage | Status |
|---|---|
| Built | Engine deployed and validated |
| Tested | Verified against live records |
| Staged | Historical remediation held for client sign-off |
The automation was never wrong. It was simply asking a question the system could not yet answer, and then never asking again.