Saturday, April 26, 2014

Auto-naming Records in Salesforce

Usually on Sales Cloud implementations, business users will want to know, "What should we name our opportunities in Salesforce?" Great question, and a better follow-up, "How can we get our users to follow this convention?"

The Best Practices for Sales Managers still recommends, "Opportunity name reflects what the deal entails. ... it will help to simply adopt a consistent opportunity naming convention." While there are many ways to automatically name a record in Salesforce, each having different pros and cons, the method described below should offer the greatest flexibility and ease of maintenance for administrator.

When implemented for Opportunities or for any object, business users will be able to:
  • Create the record with a custom name; or
  • Create the record with an automatically generated name matching the naming convention
Furthermore, business users will be able to:
  • Change the record name later, regardless of how the name was generated
  • Easily revert to the automatically generated name

One Rule. One Field. One Update.

All that's needed are three components: a formula field, a workflow rule and one field update.

For simplicity and consistency across objects, the formula field can be called Auto Name (AutoName__c), and its text output should be exactly what you would expect to see based on your naming convention. What's nice about using this formula field is that you can visually see what the result would be if you were to apply auto-naming to existing records.

Next, create a workflow rule called Set Opportunity Name, with a simple formula determining the entry criteria: LEN( Name ) <= 1. The idea is that if the user types in a single character in for the record name, which is a required field, Salesforce assumes that the user wants to apply the auto name.

Finally, add a quick field update called Opportunity Name to the workflow rule. All this field update needs to do is to set the Opportunity Name field to be exactly the same as Auto Name, using a formula.

With these three components, you can help your users make the most of auto-naming in Salesforce while still giving them the flexibility of later customization.


  1. This comment has been removed by the author.

  2. Hi..Thanks for sharing..why do we need to create formula field? Can't we use same formula in the workflow field update action directly?

    1. Yes, you absolutely can do that. For performance reasons I'd even recommend writing the formula directly in the workflow field update directly in larger orgs. However, for admins who are starting out, having the formula in a separate field makes for easy auditing, in that the admin can open a record and see whether the name matches the expected/auto name.