Auto Number
Auto Number is a Salesforce custom field type that automatically generates a unique sequential number for every new record on the object, formatted according to a display pattern the admin defines (PROJ-{0000}, CUST-{2026}-{00000}).
Definition
Auto Number is a Salesforce custom field type that automatically generates a unique sequential number for every new record on the object, formatted according to a display pattern the admin defines (PROJ-{0000}, CUST-{2026}-{00000}). The platform increments the counter on every insert; the resulting value is read-only and cannot be edited after creation. Auto Numbers are commonly used for internal record codes (Project Number, Customer Code, Internal Reference), and several standard objects (Case, Solution, Contract) ship with built-in Auto Number fields by default.
The Auto Number field exists because Salesforce's record IDs (the 15- or 18-character alphanumeric Id) are not friendly for human reference; nobody quotes "0035j00000ZXY5kAAH" on a phone call. An Auto Number gives each record a readable identifier that supports filtering, sorting, search, and integration. Beyond convenience, Auto Numbers also serve as the user-facing reference in customer-facing documents, support tickets, and downstream systems that consume Salesforce data.
Why Auto Number is one of the most-used custom field types in mature orgs
Where Auto Number lives and how to create one
Object Manager, pick the object, Fields & Relationships, New, Auto Number. The new-field wizard asks for the display format (the pattern with placeholder {0000} digits) and the starting number. Once saved, Salesforce begins assigning values on the next record insert. Existing records do not get values automatically; they need a separate one-time numbering pass (DataLoader or a Flow) if backfill is required. Plan the pattern carefully because the field cannot be retroactively reformatted without data manipulation; CUST-{000000} cannot become CUST-{0000000} without a manual update of every record.
Display format and the digit-count question
The display format mixes literal text with one or more placeholder tokens. Common patterns: PROJ-{0000} produces PROJ-0001, PROJ-0002; CUST-{2026}-{00000} produces CUST-2026-00001 with the literal year baked in. The number of digits in the placeholder is the leading-zeros padding. Pick enough digits to support the expected lifetime record count; a {0000} pattern caps at 9,999 records before rolling over to 5 digits, which produces an ugly mixed-length sequence. For long-lived objects, default to {00000000} (eight digits) even if the immediate volume is low.
Reset on year and the rolling-window pattern
Auto Numbers do not reset automatically on calendar boundaries. A pattern like INV-{0000} continues incrementing forever; INV-9999 rolls to INV-10000. Some orgs want fiscal-year reset (INV-2026-0001 starting each January). Salesforce does not support this declaratively; the pattern requires Flow or Apex on insert to compute the formatted number from the calendar year plus a year-scoped counter. The Auto Number field becomes a fallback or is replaced entirely by a custom Text field plus the Flow. This is one of the most common Auto Number limitations admins discover after deploying.
Sequence gaps and what causes them
Auto Number values are not guaranteed to be gap-free. Salesforce reserves a sequence number when an insert begins; if the insert fails (validation rule blocks save, governor limit exceeded), the reserved number is consumed and the next insert gets the next number, leaving a gap. Failed bulk inserts can produce visible jumps in the sequence. For compliance contexts that require gap-free numbering (financial documents, regulated records), Auto Number is not the right choice; build a custom Apex pattern that allocates numbers only on successful save.
Auto Number vs Formula vs Sequence-on-Insert
Three patterns produce reference numbers. Auto Number generates a sequential number at insert time and stores it. Formula fields produce a derived value at read time based on other fields. Sequence-on-Insert (custom Apex or Flow) computes a value during insert based on custom logic. Auto Number is the right choice when the requirement is a simple sequential reference. Formula fields are the right choice when the reference is derived from other fields (Account.Name + Account.AccountNumber). Sequence-on-Insert is the right choice when the requirement is fiscal-year reset, region-scoped numbering, or anything Auto Number cannot express.
Standard object Auto Numbers and renaming
Case, Solution, Contract, and a few other standard objects ship with built-in Auto Number fields (Case Number, Solution Number, Contract Number). These can be reformatted through Setup, Object Manager, the relevant object, the existing Auto Number field, Edit. The format and starting number can be changed but the existing values stay; only new records pick up the new format. Changing Case Number format mid-year leaves you with two visually distinct number patterns in your data, which is occasionally desired and occasionally a reporting headache.
Integration consumers and the Auto Number contract
Downstream systems (ERP, billing, contract management) often key on the Auto Number rather than the Salesforce ID. This creates an implicit contract; changing the Auto Number format breaks integrations that parse it. Document Auto Number formats as part of the object documentation and treat format changes as breaking changes to integrations. Some orgs version their Auto Number formats explicitly (PROJ-V2-{00000}) to signal a deliberate change; the practice helps integration teams know what to expect.
How to design an Auto Number that will not regret in three years
The setup is a one-click field create; the design is what determines whether the Auto Number serves the org for a decade or has to be replaced in year two. Most regret traces to under-sized digit counts, missing fiscal-year reset that was actually required, or formats that downstream integrations parsed assumptions into.
- Decide the format with stakeholders before creating the field
Loop in any downstream system owners. The format is an implicit contract; changing it later breaks integrations. Document the agreed format before opening Object Manager.
- Size the digit count for the expected lifetime
Default to eight digits even if current volume is low. A {0000} pattern that rolls to five digits in year three produces ugly mixed-length sequences and breaks any parsing that assumed fixed width.
- Decide whether fiscal-year reset is required
If yes, Auto Number is not the right pattern. Build a custom Text field plus a Flow or Apex that computes the value on insert. Document the choice.
- Create the Auto Number field in Object Manager
Pick the object, Fields & Relationships, New, Auto Number. Enter the format and starting number. Save. Salesforce assigns the next value on the next insert.
- Backfill existing records if needed
Auto Numbers do not retroactively populate. Use DataLoader or a Flow to assign values to existing records if the requirement covers backfill.
- Add the Auto Number to page layouts and list views
Without the field on layouts, users see the meaningful reference number only in reports. Surface it prominently for high-reference objects (Cases, Orders).
- Document the format as an integration contract
Add the format to your object documentation. Treat changes as breaking changes for downstream consumers; coordinate before modifying.
Pattern with literal text and digit placeholder. Drives the user-facing reference number.
First value assigned. Default 1; can be set higher if migrating from an existing numbering system.
Leading-zero padding. Size for expected lifetime volume; default to eight digits.
The format can be edited later, but only new records adopt the new format. Plan accordingly.
Whether and how existing records get values when the field is added to an established object.
- Auto Numbers do not reset on calendar boundaries. Fiscal-year reset requires custom Apex or Flow; the platform feature does not support it declaratively.
- Failed inserts consume sequence numbers. Auto Number is not gap-free; compliance contexts requiring gap-free numbering need custom Apex.
- Under-sized digit counts produce ugly mixed-length sequences when they roll over. Default to eight digits even when volume is low.
- Reformatting after creation does not update existing records. The org ends up with two visually distinct number patterns until existing records are updated.
- Downstream integrations often parse Auto Number formats. Changing the format is a breaking change; document the format as a contract.
Trust & references
Cross-checked against the following references.
- Auto Number referenceSalesforce
- Field types referenceSalesforce
Straight from the source - Salesforce's reference material on Auto Number.
- Auto Number FieldsSalesforce Help
- Custom Field TypesSalesforce Help
- Cases Overview (Case Number)Salesforce Help
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. What does an Auto Number field do?
Q2. Can Auto Number sequences have gaps?
Q3. Which of these is a common use for Auto Number fields?
Discussion
Loading discussion…