# Auto-populate customer references

Breww can automatically generate a unique reference for every customer, lead, and supplier you create. This is useful if you need every account in Breww to carry a short, unique code for external reporting, exports to your accounting software, or simply to give your team a consistent way to refer to an entity.

## How auto-populated references look

A reference looks like `MSA0001A` and is made up of three parts:

* **A three-letter prefix** based on the entity's name. "Mike's Sports Arena" gives `MSA`, "Local Wine Cellars" gives `LWC`. Leading articles like "The", "A", "Le", "La", "Der", "El", and similar are skipped, so "The Octagon" gives `OCT` rather than `THE`.

* **A four-digit number** that increments per prefix, starting at `0001`. Once you reach `9999` for a particular prefix, the number keeps growing (`10000`, `10001`, and so on).

* **A check character** at the end. This is a single letter or digit calculated from the rest of the reference.

Names that contain accents or non-Latin characters are transliterated first. "Ångström Ale" becomes `ANG` and "Москва Брюинг" becomes `MOS`. If a name contains no letters at all (e.g. emoji-only), the prefix falls back to `XXX`.

Each new reference is unique within your brewery, so two customers named "Mike's Sports Bar" will get `MSB0001A` and `MSB0002B` respectively.

## Turning the setting on or off

Go to **Customers** → **Settings & tools** → **Settings & tags** and use the **Auto-populate reference** setting. You can also reach the same page from **Settings** → **Customer, lead & CRM settings** → **Tags & general customer settings**.

If you switch the setting on and you have existing customers, leads, or suppliers without a reference, Breww will tell you how many there are and ask **What about entities that don't have a reference yet?**:

* **Yes, populate the missing references now** - Breww will work through your existing entities in the background and assign each one a reference. This runs after you save your settings, and you can keep using Breww while it happens. Larger accounts may take a few minutes to complete.

* **No, leave them as they are** - Only entities you create from this point forward will receive a reference. Existing entities without one stay blank.

You must pick one of the two before the settings will save.

The backfill prompt only appears the first time you turn the setting on (and only if there are entities without references to populate). You won't be asked again on subsequent saves.

## What happens when you create an entity

With the setting on, the reference field on the new customer/lead/supplier form behaves like this:

* If you leave the **Reference** field blank, Breww auto-generates one when you save.

* If you type your own reference, Breww uses what you typed. Manual references always take priority.

* As you type the entity's name, the placeholder text inside the reference field updates to show what Breww would auto-generate if you left the field blank. This is just a preview - the final reference is calculated when you save, so if someone else creates an entity with the same prefix at the same time, your reference may end up one number higher than the preview suggested.

The same applies on the edit form: if you clear the reference field on an existing entity and save, Breww will fill in a fresh auto-generated value.

## Where references are auto-populated

When the setting is on, Breww applies it everywhere new entities are created:

* **Manually**, via **Customers** → **New customer**, **Leads** → **Add lead**, or when adding a supplier.

* **From a CSV import**, via **Settings** → **Data imports and updates** → **Customers** (and the equivalent leads/supplier importers). See [Importing customers](https://breww.com/docs/importing-customers/) for the importer itself.

* **From your accountancy integration**, when downloading customers or suppliers from Xero, QuickBooks, Sage, and other connected accounting platforms.

* **From a sales platform**, when Shopify, WooCommerce, or another connected sales platform creates a new customer in Breww as part of an order sync.

In all of these cases, if a reference is supplied as part of the import or sync, Breww uses that. If the reference is missing, Breww generates one automatically.

## Manual references

You can still type your own reference at any time. Manual references aren't affected by the auto-populate setting:

* They keep whatever format you choose (within the 10-character maximum).

* They aren't replaced or "corrected" if they don't match the auto-generated format.

* Auto-generated references for the same prefix skip over them, so a manual `MBA9999XX` won't push the next auto-generated reference to `MBA10000`.

If you'd like to change a reference later, edit the customer, lead, or supplier and update the **Reference** field. References must remain unique within your brewery.

## Switching the setting off

Turning the setting off doesn't change any references that have already been assigned - it only stops Breww from generating new ones going forward. If you'd like to clear a reference, you can do so manually on the entity's edit form.

## Frequently asked questions

### Is the prefix based on the entity's name at the moment it's saved, or its current name?

At the moment it's saved. If you rename an entity later, its existing reference doesn't change.

### Can two entities ever end up with the same reference?

No. References are unique within your brewery. If two staff members happen to save new entities with the same prefix at the exact same moment, Breww will give one of them the next number in the sequence so they don't collide.

### What if I delete a customer that had a reference?

Deleted customers still hold onto their reference, so the next entity with the same prefix won't reuse the deleted one's number.

### Does this affect references on existing customers in my accounting software?

No. This setting only controls what Breww does when it creates a new entity. References that already exist in your accounting software are not changed.
