Salesforce : Dynamic Auto Number

Use Case:

We have 3 separate Sales Channel, I would like to generate different unique ID for different channel. For example:

Opportunity: Type=Online – ON-0001
Opportunity: Type=Direct – DR-0002
Opportunity: Type=Reseller – RS-0003
Opportunity: Type=Online – ON-0004

 

Solution:

  1. Create an Auto Number field (AutoNumber__c) at Opportunity level using display format {0000}. This field can be hidden from the layout.
  2. Create a Formula field with IF or Case logic:
    Case (Type,
    "Online", "ON-" + AutoNumber__c,
    "Direct", "DR-" + AutoNumber__c,
    "Reseller", "RS-" + AutoNumber__c,

 

However, this solution will not work if you need to have a separate counter for each type. For example:

Opportunity: Type=Online – ON-0001
Opportunity: Type=Direct – DR-0001
Opportunity: Type=Reseller – RS-0001
Opportunity: Type=Online – ON-0002
Opportunity: Type=Online – ON-0003
Opportunity: Type=Reseller – RS-0002

Get in touch today to see how WDCi can help your business.