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
Krish NKrish N 

Restrict Auto case-number field to specific record type

Hello,
I've a custom auto case-number field for one of my case record type (Quality Report). Every time a new case is created, the auto case number is generated (ex: QR-1287). However, the autonumber is generated even when a case is created in other record types (QR-1288, QR-1289....) . How do I avoid it? I want the auto casenumber field to update only on a single case record type, the cas enumber should QR-1288 only if the recordtype is of Quality Report. Please help. 
NagendraNagendra (Salesforce Developers) 
Hi Shashank,

Please find the below formula and tweak it as per your requirement which should probably do the trick.
IF(RecordType.Name = 'ERS','RS-',
  IF(
      AND(
         RecordType.Name = 'Service Request',
         ISBLANK(Mobile_Unit_Number__c)
         ),
        Branch_Code__c+"-", NULL
     )
  )+AutoNumber__c
For more information please refer to the below link with a similar discussion. Please mark this as solved if the reply was helpful.

Thanks,
Nagendra.
 
Krish NKrish N
Hello Nagendra,
I think the auto number will still be added for non related record type cases. It will just be without QR at the start. For ex: If a case is created on other record type, the auto case-number will 1290. If I then create a case in Quality report record type, the case will QR-1291. I would rather want the quality report case-number to be QR-1290. I want the autonumber to increment only for the specific record type.