function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravi_SFDCRavi_SFDC 

Auto Number by Record Type

Hi All,

I do have 2 record types on a standard object, based on each record type I want to generate an auto number.

Example: 

1. ABC Recordtype - Auto Number should be A2023001

2. XYZ Recordtype - Auto Number should be as Z23001


Your help would be really appreciated. 

Thanks & Regards
VinayVinay (Salesforce Developers) 
Hi Ravi,

Check below similar example using flow.

https://www.linkedin.com/pulse/salesforce-custom-auto-number-record-type-using-flow-builder-leme

Please mark as Best Answer if above information was helpful.

Thanks,
Earl HoehnEarl Hoehn

Sorry for deleted before reply it's small correction please see below
 

In Salesforce, you can achieve the desired auto-number generation based on record types by utilizing a combination of record types, formula fields, and workflow rules. 
follow to rules : 
   Create Record Types: Set up two record types for your standard object (e.g., ABC and XYZ). Ensure that the record types are configured correctly and assigned to the appropriate profiles or users.

Create a Formula Field: Create a formula field on the standard object to generate the auto number. This formula field will evaluate the record type and generate the corresponding auto number based on your requirements. The formula field should be of the text data type.
Must see and add all details.
Define Auto Numbering Logic: In the formula field, write a formula that checks the record type and generates the auto number accordingly. 
  formula: 
    IF(ISPICKVAL(RecordType.DeveloperName, "ABC"), "A" & TEXT(YEAR(TODAY())) & RIGHT("000" & TEXT(SEQUENCE(1, 9999)), 4),
IF(ISPICKVAL(RecordType.DeveloperName, "XYZ"), "Z" & TEXT(YEAR(TODAY())) & RIGHT("000" & TEXT(SEQUENCE(1, 9999)), 4),
"")) 
https://www.paymydoctor.ltd/

萍生 劉萍生 劉
Hi, I followed the solution you provided, but the SEQUENCE formula can't work in Salesforce.