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
Melissa GMelissa G 

Conditional Autonumbering Based on Picklist Value

Good morning! I was wondering if it is possible to generate an auto-number value only if a certain value is selected from a picklist. For example, I am setting up cases for our internal salesforce support team. I would like a way to track defects so I can report on them later. I have a subtype picklist field (Sub_Type__c) that contains a value of 'Defect'. I also have a defect number field (Defect_Number__c) that is an auto number. I would like to only assign an auto number when 'Defect' is selected from the picklist. Enhancement, another value, would not get a defect number, for example.

If there is a better way to do this please let me know as well. I see this is an enhancement requested to Salesforce but I did not see that it has implemented to this point. I assume there must be work-arounds then.

Thanks so much!!
This is not something you can do with the built in auto-number system.  You would have to either roll your own auto-number system, split this into two differnt objects (enhancement and defect) or hide the autonumber via a visualforce page if the picklist is an enhancement.