---
title: Global HubSpot lead routing the sales team can manage itself
description: How we replaced a fragile lead routing code block with a HubDB rules table that sales operations can manage, across North America and Europe.
image: https://www.revm.com/hubfs/health-lifesciences-bench%20(1).png
---

[![RevM logo](https://www.revm.com/hubfs/revm-nav-logo-white.png)](https://www.revm.com/)

[Services▾](https://www.revm.com/services)

##### What *we do*

Everything we design, build and run inside HubSpot, for your people, HubSpot's AI agents and the custom AI agents we build.

###### Start here

[**Revenue Reset & Audit**For businesses already on HubSpot](https://www.revm.com/services/revenue-reset)[**Revenue Architecture**For new HubSpot builds and rebuilds](https://www.revm.com/revenue-architecture)

[All services →](https://www.revm.com/services)

###### [Demand architecture](https://www.revm.com/services/hubspot-demand-architecture)

[**Marketing automation**](https://www.revm.com/services/hubspot-demand-architecture#marketing-automation)[**Lead scoring and buyer intent**](https://www.revm.com/services/hubspot-demand-architecture#lead-scoring-and-buyer-intent)[**SEO and AEO**](https://www.revm.com/services/hubspot-demand-architecture#seo-and-aeo)[**Events and campaigns**](https://www.revm.com/services/hubspot-events-and-campaigns)[**Websites and CMS**](https://www.revm.com/services/hubspot-demand-architecture#websites-and-cms)[**Email templates**](https://www.revm.com/services/hubspot-email-templates)[**Creative, brand and content**](https://www.revm.com/services/hubspot-demand-architecture#creative-brand-and-content)

###### [RevOps architecture](https://www.revm.com/services/hubspot-revops-architecture)

[**Lead to Revenue**](https://www.revm.com/services/hubspot-revops-architecture#lead-to-revenue)[**Reporting and forecasting**](https://www.revm.com/services/hubspot-revops-architecture#reporting-and-forecasting)[**Billing, payments and subscriptions**](https://www.revm.com/services/hubspot-revops-architecture#billing-payments-and-subscriptions)[**Billing portal**](https://www.revm.com/services/hubspot-revops-architecture#billing-portal)[**Finance and ERP integrations**](https://www.revm.com/services/hubspot-revops-architecture#finance-and-erp-integrations)[**Revenue operations**](https://www.revm.com/services/hubspot-revops-architecture#revenue-operations)

###### [Customer experience architecture](https://www.revm.com/services/hubspot-customer-experience-architecture)

[**Service Hub and help desk**](https://www.revm.com/services/hubspot-customer-experience-architecture#service-hub-and-help-desk)[**Customer success and retention**](https://www.revm.com/services/hubspot-customer-experience-architecture#customer-success-and-retention)[**Knowledge base**](https://www.revm.com/services/hubspot-customer-experience-architecture#knowledge-base)[**Customer support portal**](https://www.revm.com/services/hubspot-customer-experience-architecture#customer-support-portal)[**Project and service delivery management**](https://www.revm.com/services/hubspot-customer-experience-architecture#project-and-service-delivery)

###### [Platform architecture](https://www.revm.com/services/hubspot-platform-architecture)

[**AI agent design and build**](https://www.revm.com/services/hubspot-platform-architecture#ai-agent-design-and-build)[**HubSpot AI and agents**](https://www.revm.com/services/hubspot-platform-architecture#hubspot-ai-and-agents)[**Custom intelligence and reporting**](https://www.revm.com/services/hubspot-platform-architecture#custom-intelligence-and-reporting)[**CRM architecture and implementation**](https://www.revm.com/services/hubspot-crm)[**CRM migrations**](https://www.revm.com/services/hubspot-crm-migration)[**HubSpot onboarding**](https://www.revm.com/services/hubspot-onboarding)[**Integrations and APIs**](https://www.revm.com/services/hubspot-platform-architecture#integrations-and-apis)[**Data quality and governance**](https://www.revm.com/services/hubspot-platform-architecture#data-quality-and-governance)

###### Ongoing

[**AI agent development and management**](https://www.revm.com/services/hubspot-managed-services)[**Managed services**](https://www.revm.com/services/hubspot-managed-services)[**Optimisation**](https://www.revm.com/services/hubspot-managed-services)[**Training and enablement**](https://www.revm.com/services/hubspot-onboarding)

[Sectors▾](https://www.revm.com/sectors/b2b-saas)

##### Sectors we *work in*

HubSpot set up around how each type of business sells, delivers and gets paid, for people and AI agents alike.

[**SaaS and technology**Subscriptions, ARR and renewals](https://www.revm.com/sectors/b2b-saas)[**Financial services**Brokers, compliance and audit trail](https://www.revm.com/sectors/financial-services)[**Health and life sciences**Bids, approved content and projects](https://www.revm.com/sectors/health-life-sciences)[**Professional services**Key accounts and practices](https://www.revm.com/sectors/professional-services)[**Education and training**Institutions, enrolment and cohorts](https://www.revm.com/sectors/education)[**Media and membership**Audiences, events and renewals](https://www.revm.com/sectors/media-and-membership)[**Private equity and VC**One HubSpot standard across a portfolio](https://www.revm.com/private-equity)

[Not sure where to start?**Start with a Revenue Reset** A senior review of your HubSpot in three weeks, with a phased plan for people and AI agents. *Find out more →*](https://www.revm.com/services/revenue-reset)

[Resources▾](https://www.revm.com/blog)

##### Ideas and *evidence*

What we have learned from working inside HubSpot since 2012.

[**Articles and guides**HubSpot, RevOps and AI](https://www.revm.com/blog)[**Case studies**Work for clients like you](https://www.revm.com/case-studies)[**HubSpot FAQs**Answers to common HubSpot questions](https://www.revm.com/faqs)

[Talk to us**Talk to us about your HubSpot** Tell us what you need and we will tell you plainly how we would approach it. *Get in touch →*](https://www.revm.com/contact)

[About▾](https://www.revm.com/about)

##### Who *we are*

A senior team of HubSpot architects, designers, developers and AI engineers, led by our founder.

[**About RevM**Our story and our team](https://www.revm.com/about)[**HubSpot partner**Our HubSpot Solutions Partnership](https://www.revm.com/hubspot-partner)[**HubSpot DNA**Inside HubSpot since 2012](https://www.revm.com/hubspot-dna)

[Not sure where to start?**Start with a Revenue Reset** A senior review of your HubSpot in three weeks, with a phased plan for people and AI agents. *Find out more →*](https://www.revm.com/services/revenue-reset)

[Contact us](https://www.revm.com/contact)

Services

Start here[Revenue Reset & Audit](https://www.revm.com/services/revenue-reset)[Revenue Architecture](https://www.revm.com/revenue-architecture)[Demand architecture](https://www.revm.com/services/hubspot-demand-architecture)[Marketing automation](https://www.revm.com/services/hubspot-demand-architecture#marketing-automation)[Lead scoring and buyer intent](https://www.revm.com/services/hubspot-demand-architecture#lead-scoring-and-buyer-intent)[SEO and AEO](https://www.revm.com/services/hubspot-demand-architecture#seo-and-aeo)[Events and campaigns](https://www.revm.com/services/hubspot-events-and-campaigns)[Websites and CMS](https://www.revm.com/services/hubspot-demand-architecture#websites-and-cms)[Email templates](https://www.revm.com/services/hubspot-email-templates)[Creative, brand and content](https://www.revm.com/services/hubspot-demand-architecture#creative-brand-and-content)[RevOps architecture](https://www.revm.com/services/hubspot-revops-architecture)[Lead to Revenue](https://www.revm.com/services/hubspot-revops-architecture#lead-to-revenue)[Reporting and forecasting](https://www.revm.com/services/hubspot-revops-architecture#reporting-and-forecasting)[Billing, payments and subscriptions](https://www.revm.com/services/hubspot-revops-architecture#billing-payments-and-subscriptions)[Billing portal](https://www.revm.com/services/hubspot-revops-architecture#billing-portal)[Finance and ERP integrations](https://www.revm.com/services/hubspot-revops-architecture#finance-and-erp-integrations)[Revenue operations](https://www.revm.com/services/hubspot-revops-architecture#revenue-operations)[Customer experience architecture](https://www.revm.com/services/hubspot-customer-experience-architecture)[Service Hub and help desk](https://www.revm.com/services/hubspot-customer-experience-architecture#service-hub-and-help-desk)[Customer success and retention](https://www.revm.com/services/hubspot-customer-experience-architecture#customer-success-and-retention)[Knowledge base](https://www.revm.com/services/hubspot-customer-experience-architecture#knowledge-base)[Customer support portal](https://www.revm.com/services/hubspot-customer-experience-architecture#customer-support-portal)[Project and service delivery management](https://www.revm.com/services/hubspot-customer-experience-architecture#project-and-service-delivery)[Platform architecture](https://www.revm.com/services/hubspot-platform-architecture)[AI agent design and build](https://www.revm.com/services/hubspot-platform-architecture#ai-agent-design-and-build)[HubSpot AI and agents](https://www.revm.com/services/hubspot-platform-architecture#hubspot-ai-and-agents)[Custom intelligence and reporting](https://www.revm.com/services/hubspot-platform-architecture#custom-intelligence-and-reporting)[CRM architecture and implementation](https://www.revm.com/services/hubspot-crm)[CRM migrations](https://www.revm.com/services/hubspot-crm-migration)[HubSpot onboarding](https://www.revm.com/services/hubspot-onboarding)[Integrations and APIs](https://www.revm.com/services/hubspot-platform-architecture#integrations-and-apis)[Data quality and governance](https://www.revm.com/services/hubspot-platform-architecture#data-quality-and-governance)Ongoing[AI agent development and management](https://www.revm.com/services/hubspot-managed-services)[Managed services](https://www.revm.com/services/hubspot-managed-services)[Optimisation](https://www.revm.com/services/hubspot-managed-services)[Training and enablement](https://www.revm.com/services/hubspot-onboarding)[All services →](https://www.revm.com/services)

Sectors

[SaaS and technology](https://www.revm.com/sectors/b2b-saas)[Financial services](https://www.revm.com/sectors/financial-services)[Health and life sciences](https://www.revm.com/sectors/health-life-sciences)[Professional services](https://www.revm.com/sectors/professional-services)[Education and training](https://www.revm.com/sectors/education)[Media and membership](https://www.revm.com/sectors/media-and-membership)[Private equity and VC](https://www.revm.com/private-equity)

Resources

[Articles and guides](https://www.revm.com/blog)[Case studies](https://www.revm.com/case-studies)[HubSpot FAQs](https://www.revm.com/faqs)

About

[About RevM](https://www.revm.com/about)[HubSpot partner](https://www.revm.com/hubspot-partner)[HubSpot DNA](https://www.revm.com/hubspot-dna)

[Contact us](https://www.revm.com/contact)

Health and life sciences

# Global HubSpot lead routing the sales team can manage

A global life sciences company with sales teams across North America and Europe.

The challenge

## Over 100 territory rules inside one block of code

Every new contact needed to reach the right sales rep, and the rules for deciding who that was changed from one market to the next. In the United States, territories were set by zip code, with several reps sharing a single metro area. Elsewhere in North America the split was by state. In Europe, some reps covered a whole country, some covered several, and in at least one country the territory was divided by region.

All of that logic lived in a single custom code action inside a HubSpot workflow. It had been written some years earlier and ran to tens of thousands of characters. Rep IDs, long strings of zip codes and the order in which rules were checked were all written into the code itself, and some of them appeared in more than one place. The code had grown as the sales team changed around it.

The context

## One small mistake could stop leads reaching anyone

Changing a single territory meant finding every place it appeared and editing the code by hand. A missing comma, a stray quote mark or a zip code pasted into the wrong list could break the whole action, or quietly send leads to the wrong rep. Nothing would flag the error at the time of the edit. The first sign would be a rep asking why their leads had dried up, or a new lead sitting with nobody.

**Nobody could see who owned what**  
There was no simple view of a rep's territory. To answer a basic question such as "which zip codes does this rep cover?" someone had to read through the code and piece it together. Overlaps between reps were hidden in the order of the code, so a territory could end up claimed twice without anyone noticing. Sales leadership had no way to review the territories without asking someone technical to explain them.

“

I'm over the moon, Carl, I really am.

ML

HubSpot team, global life sciences company

What we did

## A rules table in HubDB and a small code action that never needs editing

01

Moved every rule into a HubDB table

HubDB is HubSpot's built-in database tool, and it was already part of the company's HubSpot subscription. We created a single table to hold the routing rules. Each row is one rule: the rep who should receive the contact, what to match on and the values to match.A rule can match on country code, country name, state or region code, or zip code. That covers every pattern the business uses, from a rep with a whole European country to a rep with a list of zip codes in one city. Our team took the existing code apart, worked through it rule by rule, and rebuilt it as just over 100 rows in the table.

02

Set the order rules are checked in

Some territories overlap. A rep might own specific zip codes in a state while another rep picks up the rest of that state. Each row has a check order, so the most specific rules are tested first and the broad catch-all rules sit at the bottom. We left gaps between the check order numbers, so a new rule can be slotted in between two existing ones without renumbering the table.

03

Made the table easy to read and maintain

Reps are listed by name, so nobody has to look up owner IDs. A notes column records why a rule exists or when it changed. Each rule can be switched off without being deleted, which also means the team can keep a short history when a territory moves from one rep to another and tidy it up later.Filtering the table by a rep's name shows every rule they own in seconds. The whole table can be exported to a spreadsheet for sales leadership to review, then imported back once changes are agreed.

04

Replaced the old code with a short, fixed code action

The workflow keeps the same enrolment criteria. The custom code action now does one thing: it reads the published HubDB table, works through the rules in check order and returns the matching owner. All of the routing logic now lives in the table, so the code action only needs to change if the business adds a new type of rule.

The outcomes

## Territory changes in minutes, without a developer

 100

ROUTING RULES

Every territory across North America and Europe held in one table, in check order.

 0

LINES OF CODE TO EDIT

Territory changes are made in the table. The code action stays as it is.

 £0

EXTRA SUBSCRIPTIONS

Built with HubDB and workflows the company already had in HubSpot.

What came next

## Tested by the team, then live

The new routing was built and tested in the company's sandbox portal and handed to the sales operations team to review with sales leadership. Once they are happy with the rules, it moves to the live portal.  
"I think that will probably solve the issue and make it so much easier to manage."  
HubSpot team, global life sciences company"I can run it through with the team, watch them hopefully light up as much as I just have."  
HubSpot team, global life sciences company  
If the business ever wants a dedicated marketplace app later, the rules are already clean, documented and ready to move

[← Back to all work](https://www.revm.com/case-studies-old)

Revenue Architecture for HubSpotBuilt for people and AI agents[Talk to us →](https://www.revm.com/contact)

[![RevM](https://www.revm.com/hubfs/revm-nav-logo-white.png)](https://www.revm.com/)

Revenue systems engineered inside HubSpot, so people and AI agents can drive outcomes together.

[Start with a Revenue Reset →](https://www.revm.com/services/revenue-reset)

#### What we do

- [Revenue Reset](https://www.revm.com/services/revenue-reset)
- [Services](https://www.revm.com/services)
- [Revenue Architecture](https://www.revm.com/revenue-architecture)
- [HubSpot DNA](https://www.revm.com/hubspot-dna)

#### Who we work with

- [Sectors](https://www.revm.com/sectors/b2b-saas)
- [Case studies](https://www.revm.com/case-studies)
- [Resources](https://www.revm.com/blog)

#### Company

- [About](https://www.revm.com/about)
- [Contact](https://www.revm.com/contact)
- [LinkedIn](https://www.linkedin.com/company/revm/)

Partners, awards and certifications [![HUBSPOT SOLUTION PARTNER PLATINUM](https://www.revm.com/hubfs/SolutionPartnerTierBadges_FINAL_PLATINUM_CREAM.svg)](https://ecosystem.hubspot.com/marketplace/solutions/revm) ![HubSpot EMEA Impact Award for RevM](https://www.revm.com/hs-fs/hubfs/Revm%20HubSpot%20Award.png?width=120&height=120&name=Revm%20HubSpot%20Award.png) [![Insycle Partner Program](https://www.revm.com/hs-fs/hubfs/Insycle%20Partner%20Program.png?width=200&height=83&name=Insycle%20Partner%20Program.png)](https://insycle.co/3IsLsEb)

<iframe src="https://registry.blockmarktech.com/certificates/791dd46e-4648-4ebb-8cb0-5d29863aa54d/widget/?tooltip_position=bottom_right&amp;theme=transparent&amp;hover=t" style="border:none;height:64px;width:64px;" loading="lazy"></iframe>

© 2026 RevM Limited [Privacy Policy](https://www.revm.com/privacy-policy)[Cookie Policy](https://www.revm.com/cookie-policy)[Terms of use](https://www.revm.com/website-terms-of-use)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Carl Davies",
    "url" : "https://www.revm.com/case-studies/author/carl-davies"
  },
  "dateModified" : "2026-10-23T08:51:07.892Z",
  "datePublished" : "2026-10-21T17:58:22.000Z",
  "headline" : "Global HubSpot lead routing the sales team can manage itself",
  "image" : [ "https://www.revm.com/hubfs/health-lifesciences-bench%20(1).png" ],
  "mainEntityOfPage" : {
    "@id" : "https://www.revm.com/case-studies/global-lead-routing-the-sales-team-can-manage-itself",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://www.revm.com/hubfs/RevM%20Logo_full%20colour_transparent%20@3x-8.png"
    },
    "name" : "RevM"
  }
}
```