Advanced Object Naming Strategies in Salesforce

Object names are the primary means of record identification in Salesforce. Salesforce offers two primary approaches to object naming: auto-generated names and user-provided names. Auto-generated names are unique, but quite simple — just a sequence number with optional prefix/suffix (e.g., CNTRCT-012412). User-provided names can be complex (anything a user wants!) but are not unique.

 

A screenshot of Salesforce Object Manager with object name format selection.
Salesforce object name format selection.

In some cases, object names need to reflect information from other fields. For example, an opportunity name might incorporate details like quantities, product codes, SKUs, or customer types. “A name such as ’10 widgets for Acme Corp’ provides context and enables users to immediately understand what they are looking at.

This post explores advanced strategies for object naming that go beyond Salesforce’s out-of-the-box capabilities.

Object Naming Example: A Subscription Service

Subscription services, such as hosted databases, bare-metal servers, SaaS applications, or broadband Internet, often require a reference number for billing and support purposes. These identifiers can range from a simple ID to a more structured generated name, such as “SRV-000001” in Salesforce.

However, in most cases, the name carries additional information, such as the product (linked to a product lookup or record type), customer type, region, initial term start date, or other relevant details. This extra context helps back-office teams quickly identify the subscription service without digging into the details, significantly improving their efficiency.

For example, a naming convention like “B-INTERNET-100-000001” might represent the following:

  • B-INTERNET: Business Internet service (product code),
  • 100: 100 Mbps speed,
  • 000001: Unique identifier for the subscription.

This type of structured naming scheme cannot be achieved with Salesforce’s standard auto-naming, requiring the use of regular object names supplemented by custom coding.

The First Step: Ensuring Name Uniqueness

Auto-naming in Salesforce inherently guarantees unique names. However, this is not the case for user-provided names, which can lead to duplication issues. In the subscription service example, ensuring uniqueness is critical to avoid confusion in support or billing processes.

Therefore, the first step in the implementation is to enforce name uniqueness, ensuring that each record can be reliably identified.

While there is no ‘unique name’ option in the Salesforce user interface, it can be implemented using VLOOKUP within a validation rule. For instance, to ensure that Contract__c object has unique name, the validation rule could look as follows:

(
   ISCHANGED(Name) && 
   Name = VLOOKUP($ObjectType.Contract__c.Fields.Name, $ObjectType.Contract__c.Fields.Name, Name)
) 
||
(
   ISNEW() && 
   Name = VLOOKUP($ObjectType.Contract__c.Fields.Name, $ObjectType.Contract__c.Fields.Name, Name)
)
 

Object Naming: Strategies and Implementation Options

Once ensuring name uniqueness is out of the way, the following options are available for name generation:

OptionProsCons
User-provided
  • Easy to configure — standard out-of-the box functionality
  • Recoverable via backup
  • Users must provide names
  • Names are not unique (but that can be mitigated using validation rules, as shown above)
  • Names can change (are user-editable)
User-provided with ensured uniqueness
  • Names are guaranteed to be unique
  • Recoverable via backup
  • Users must provide names
  • Names can change (are user-editable)
User-provided with ensured uniqueness and additional validation
  • Names are guaranteed to be unique
  • Names are guaranteed to follow a required syntax
  • Recoverable via backup
  • Users must provide names — high likelihood of mistakes
  • Names can change (are user-editable)
Generated name (e.g., SRV-000001)
  • Easy to configure — standard out-of-the box functionality
  • Unique, consistent names
  • Simple syntax
  • Not easily recoverable via backup (see notes below)

Good choice for simple names but not ones that hold an important reference or shared with customers (see notes on backup below)

Overwriting standard name with a trigger or workflow
  • Full control over naming process
  • Can be also applied to standard objects such as opportunities, etc.
  • Requires some APEX or workflow programming effort
  • Name cannot be made read-only on layouts so users will have to enter a value that will be overwritten

Good choice for complex names, works great with backup and data cleanup tools

Formula derived or trigger generated fabricated name
  • Full control over naming process
  • Not shown as object link in lookup fields, reports, etc.

Good choice for secondary identifiers (e.g., adding Opportunity Code/Reference to the standard opportunity object)

Generating Unique Name Parts

Even when generating names automatically (e.g., via a trigger), a unique component is most likely required to ensure name uniqueness.

For example, in the “B-INTERNET-100-000001” example above, multiple instances of the “B-INTERNET-100” product may exist, so a unique suffix is necessary.

There are two primary methods for achieving this:

  • AutoNumber Field: Add an AutoNumber field directly to the object and incorporate it into the trigger code.
  • Custom Setting Variable: Use a Custom Setting variable to track the current number, handling increments programmatically in the trigger code.

While the Custom Setting approach is more complex to implement, it offers greater control over numbering. For instance, the current value can be manually adjusted as needed. This method is commonly employed in Nextian products.

Backup Considerations

One significant limitation of auto-generated names is that they may not restore correctly from backups. If an object is deleted and later recovered, a new name is generated instead of retaining the original one. For instance, an object named OBJ-0001 might be restored as OBJ-0052, potentially causing confusion or inconsistencies. This limitation should be considered when selecting an object naming strategy.

One problem with auto-generated names is that they are not restoring correctly from backups. If an object is deleted and recovered, the new name will be generated anew, e.g., OBJ-0001 could become (for example) OBJ-0052.

ImportantAt Nextian, we typically recommend using standard auto-generated names only for objects where names carry no special significance, such as junction objects.

An Alternate Approach: User-Initiated, Manual Name Standardization

In some scenarios, strict naming rules may not be practical. For instance, consider a CRM opportunity where the sales representative initially knows only the account details but lacks information about products, quantities, or the number of sites needed for a complete name.

In such cases, it’s often better to allow users the flexibility to enter any name initially. A dedicated action button, such as Standardize Name” can then be used to update the name based on a predefined convention once the required details are available.

For example, At Nextian, we use this approach for standardizing service address names to conform to the Google address format:A screenshot of Nextian service address with 'Standardize Name' option.

 

Conclusions

In some cases, out-of-the-box Salesforce object naming options (user-provided or auto-generated) may not be sufficient. These limitations however can be overcome with APEX programming, validation rules, actions or their combination.

Nextian has extensive experience in implementing complex Salesforce customizations with Apex and Lightning, helping our clients unlock the full potential of their Salesforce.

Contact us today to find out how we can help you!

    Thank you for contacting Nextian. Your request was successfully submitted, we will get back to you within two working days.

    BY INDUSTRY

    Cloud Infrastructure Providers

    Cloud Software Companies

    Managed Service Providers

    Communications Service Providers

    BY ROLE

    CEO / Owner

    CRO / VP Sales

    CFO / VP Finance

    COO / VP Operations

    CPO / VP Product

    CIO / VP IT

    Product Management

    Plan, launch and manage your product offerings throughout their entire lifecycle.

    CPQ & Sales

    Quickly create accurate quotes for complex products, subscriptions and add-ons

    Order Management

    Ensure faster, consistent order delivery with tasks, workflows and automation

    Service Management, Support & Monitoring

    Retain and upsell customers with comprehensive account intelligence, support, monitoring, analytics

    Customer Portal

    Empower your customers with 24/7 self-service, support and on-line ordering

    NEXTIAN PLATFORM

    Platform Overview

    Billing Integration

    Network Monitoring Integration

    Reporting & Analytics