How to Create an Auto-Number Field in Salesforce Lightning (Step-by-Step)

If you want Salesforce to automatically generate a unique number or ID for records, such as CASE-0001, OPP-00023, or REQ-000100, you can use an Auto Number field.

An Auto Number field is one of the most useful field types in Salesforce because Salesforce automatically creates a unique value for every new record.

You don’t need to write Apex code, create a Flow, or use formulas. You just configure the field once, and Salesforce handles the numbering automatically.

In this tutorial, I’ll show you how to create an Auto Number field from scratch in Salesforce Lightning Experience, explain what each setting means, and share some useful tips to help you configure it correctly the first time.

What Is an Auto-Number Field in Salesforce?

An Auto Number field in Salesforce automatically generates a unique sequential number whenever a new record is created.

You only need to define the format once, and Salesforce automatically generates the values for all future records.

Here are some important features of an Auto Number field:

  • It is system-generated, so users cannot manually enter or edit the value.
  • Every generated value is unique for records in that object.
  • You can add custom prefixes or suffixes to make the number more meaningful, such as INV-0001 for invoices or TASK-0001 for tasks.
  • Auto Number fields can be created on both standard objects (like Cases and Opportunities) and custom objects.

For example, the standard Case Number field in Salesforce is an Auto Number field.

When you create your own Auto Number field, you implement functionality similar to that of the Auto Number field to meet your custom business requirements.

When Should You Use an Auto-Number Field?

Auto Number fields are useful when you need:

  • A human-readable unique identifier for records, which is easier to use than the Salesforce Record ID.
  • Sequential numbering for records such as support tickets, orders, requests, invoices, or applications.
  • A consistent ID format for integrations with external systems.
  • A cleaner and more professional record format for users and customers.

However, Auto Number fields may not be the right choice in the following situations:

  • When users need to manually enter or control the numbering.
  • When the numbering needs to reset automatically after a certain period, such as every month or year. Salesforce does not support this functionality by default, so additional customization is required.
  • When the field value needs to be editable after the record is created.

Configure the Display Format for Auto Number Fields

Before creating the Auto Number field, it’s important to understand the Display Format setting because this is where most beginners make mistakes.

The Display Format defines how the auto-generated number will appear on records. It mainly contains two parts:

  • A text prefix or suffix (optional), such as CASE-, INV-, or 2025-
  • A number pattern inside curly braces, such as {0000}. The number of zeros determines the minimum number of digits in the sequence.

For example:

  • CASE-{0000} → CASE-0001, CASE-0002
  • INV-{00000} → INV-00001, INV-00002

Salesforce automatically increases the number whenever a new record is created.

Here are a few examples:

Display FormatWhat You See on Records
CASE-{0000}CASE-0001, CASE-0002 … CASE-9999
INV-{000000}INV-000001, INV-000002 … INV-999999
{00000}00001, 00002 … 99999
REQ/{0000}/2025REQ/0001/2025, REQ/0002/2025

The zeros inside the curly braces work as number padding. They tell Salesforce to display at least that many digits by adding leading zeros when needed.

For example:

  • {0000} generates values like 0001, 0002, 0003
  • {00000} generates values like 00001, 00002, 00003

If the record count exceeds the defined digit length, Salesforce automatically increases the number length instead of stopping the sequence.

For example:

  • CASE-9999 becomes CASE-10000

A good practice is to use more digits than you currently need. For example, if you think your object may have fewer than 10,000 records, it is better to use {00000} instead of {0000}.

This gives you extra flexibility in the future and helps maintain a consistent record format.

How to Create an Auto-Number Field in Salesforce

Now, let’s create the Auto Number field step by step.

In this example, I’ll use a custom Support Ticket object, but the same steps apply to both standard and custom objects in Salesforce.

Step 1: Open Object Manager

  1. Click the gear icon in the top-right corner of Salesforce
  2. Select Setup
  3. In the Setup search bar (Quick Find), type Object Manager and click on it

You’ll see a list of all your standard and custom objects.

How to create an auto number field type in Salesforce

Step 2: Select Your Object

Click on the object where you want to add the auto-number field. For this example, I’m clicking on my Support Ticket custom object.

If you’re adding it to a standard object like Opportunities or Cases, just search for and click on that object name.

How to create an auto number field type in Salesforce Lightning

Step 3: Go to Fields & Relationships

In the left-hand sidebar of the object, click Fields & Relationships.

You’ll see all the existing fields on this object. To add a new one, click the New button in the top-right corner.

Step 4: Select Auto Number as the Field Type

You’ll see a list of all available field types. Scroll down or look for “Auto Number” and click it.

Then click Next.

Create an auto number field type in Salesforce

Step 5: Configure the Field Settings

This is the most important step — you’re defining how the field looks and behaves. Here’s what each setting means:

Field Label
This is the name users will see on the record. Make it clear and descriptive.
Example: Ticket Number, Invoice ID, Request Number

Field Name
Salesforce auto-populates this based on the label. It becomes the field’s API name (e.g., Ticket_Number__c). You can leave this as-is unless you have a specific naming convention to follow.

Display Format
This is where you define the format pattern. Enter your prefix and number padding here.
Example: TICKET-{00000}

Click the “What Is This?” link next to the field to see Salesforce’s own format guide inline.

Starting Number
This is the number Salesforce will assign to the very first new record created after you save the field.

  • Use 1 if you’re starting fresh
  • Use a higher number if you want to match an existing sequence (e.g., start at 1001 to align with a legacy system that already has tickets 1–1000)
Create an Auto-Number Field in Salesforce

Generate Auto Number for Existing Records
This checkbox appears when you’re adding an auto-number field to an object that already has records.

  • Check it if you want Salesforce to retroactively assign auto-number values to your existing records. Salesforce will assign numbers starting from your starting number.
  • Leave it unchecked if you only want new records to receive auto-numbered values going forward. Existing records will have a blank auto-number field.

For most cases, I recommend checking it — it keeps your data clean and consistent.

Description (optional)
An internal note about what this field is for. Only visible in Setup, not on records. Worth filling in for team clarity.

Help Text (optional)
Shows as a tooltip on the record when users hover over the field. Useful if you want to explain what the number represents to end users.

Once you’ve filled everything in, click Next.

Step 6: Set Field-Level Security

Field-Level Security controls which user profiles can see the field.

Since auto-number fields are read-only by design, you typically want to make the field Visible for all relevant profiles. It can never be edited regardless of the profile setting.

Check Visible for the profiles that should see the field on records. For most situations, enabling it for all profiles is fine.

Click Next.

How to create auto number field type in Salesforce

Step 7: Add the Field to Page Layouts

On this screen, Salesforce asks which page layouts should include this field. Check the layouts where you want the auto-number to appear on the record detail page.

If you’re unsure, just check them all — you can always remove them from a layout later.

Click Save.

How to create auto number field type in Salesforce Lightning

Proof of Concept

Once you click Save, Salesforce starts assigning auto-number values. If you checked “Generate Auto Number for Existing Records,” Salesforce will process all existing records in the background — this may take a few minutes on large objects.

To verify it worked, open any record on that object. You should see your new field with its auto-generated value.

Create Auto Number Field Type in Salesforce

A Real Example: Adding an Order Number to a Custom Object

Let me walk through a quick real-world scenario so this feels more concrete.

Say you have a custom object called Service Request and you want every new request to automatically get a number like SR-00001, SR-00002, and so on.

Here’s what I’d configure:

  • Field Label: Request Number
  • Display Format: SR-{00000}
  • Starting Number: 1
  • Generate Auto Number for Existing Records: Checked

After saving, the first new Service Request created will show SR-00001 in the Request Number field. The next one will show SR-00002. Salesforce handles everything else automatically.

If you later hit SR-99999 (record 99,999), Salesforce expands the number to SR-100000 — no errors, just a longer number. That’s why I used 5 digits instead of 4 here — it gives you 99,999 records before any visual expansion happens.

Important Things to Know After Creating the Field

You cannot edit auto-number values manually.
The field is always read-only for everyone, including System Admins. If you need to update the value on an existing record, you’d need to temporarily convert the field to Text, update the records via Data Loader, and convert back.

Deleting a record does not reuse its number.
If record TICKET-00100 gets deleted, the next record created will still be TICKET-00101. Salesforce never reuses auto-number values from deleted records.

The sequence doesn’t restart automatically.
If you want to reset the sequence (e.g., start from 1 again), you’ll need to use the field-type conversion workaround described in the reset guide. Salesforce doesn’t support automatic resets.

Auto-number fields can be used as External IDs.
When creating the field, you can check the External ID box. This lets you use the auto-number value as a unique reference key during data imports and API operations — especially useful when syncing with an external system.

Common Display Format Mistakes to Avoid

A few things I see admins get wrong when setting up the format:

  • Using too few digits — {000} only gives you 999 records before the number expands. Unless your object will never have more than a few hundred records, use at least {00000}.
  • Forgetting the curly braces — If you type CASE-0000 instead of CASE-{0000}, Salesforce will treat the entire thing as a static text prefix. Your records will all show CASE-0000 — the same value every time.
  • Using special characters in the prefix — Characters like #, @, and % can cause issues in integrations and SOQL queries. Stick to letters, numbers, and hyphens.
  • Making the total length too long — The entire auto-number value (prefix + number + suffix) can’t exceed 30 characters. If your prefix is long, make sure your digit count still fits within that limit.

Frequently Asked Questions

Can I add an auto-number field to a standard object, such as Account or Opportunity?

Yes. The process is identical. Go to Object Manager, select the standard object, and follow the same steps.

Just note that some standard objects already have built-in auto-number fields (like Case Number on Cases) — adding a second one is fine, but it’s worth asking whether you actually need both.

Can I have more than one auto-number field on the same object?

Yes, you can add multiple auto-number fields to a single object, each with its own independent sequence.

For example, one field might track Invoice-{00000} and another might track Ref-{00000} — they each increment separately.

Is an auto-number field the same as a Record ID?

No. Every Salesforce record has a system-generated Record ID (an 18-character alphanumeric string like 0015g00001XYZabcABC).

An auto-number field is separate from that — it’s a human-readable sequential number you define. The system uses the Record ID; people use the auto-number.

Can I use an auto-number value in a Formula field?

Yes. Auto-number fields can be referenced in Formula fields just like any other text field.

For example, you could create a formula that combines the auto-number with another field value to create a composite identifier.

What happens to the auto-number if a record creation fails or is rolled back?

Salesforce still “consumes” that number. If record creation fails midway and is rolled back, the auto-number reserved for that record is skipped.

So you might see gaps in your sequence (e.g., TICKET-00101 followed by TICKET-00103). This is normal behavior and not something to worry about.

Conclusion

Creating an auto-number field in Salesforce Lightning is genuinely one of the easier admin tasks — the UI guides you through it clearly, and there’s no code involved. The main thing to get right is the display format and the digit count.

Spend an extra 30 seconds thinking about how many records this object will ever have, and pick your digit padding accordingly. Future-you will appreciate it.

You may like to read:

live webinar

Salesforce Data Cloud with Agentforce Data Library

In this live webinar, we will showcase how Salesforce AI Agents use business data and documents to provide intelligent responses using Agentforce Data Library and Salesforce Data Cloud.

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.