+ Start a Discussion
Jiahao Zheng 33Jiahao Zheng 33 

Auto generate 6 digit number for a custom field

Hi Trailblazers, I have a custom field called CNO/RNO__c on the standard Account object and I want to customize this CNO/RNO__c field to auto generate 6 digit number wheneven a new Account object is created. Is it possible to do it using Formula? Or we need to apply Apex code here? 
 
Best Answer chosen by Jiahao Zheng 33
VinayVinay (Salesforce Developers) 
You can create account record not an account object.  You can generate random number once you set the start value.  Eg. Salesforce-0001,  Salesforce-0002 etc based on your prefix or only number.

User-added image

Let me know if you have any additional questions

Please mark as Best Answer if above information was helpful so that it can help others in the future.

Thanks,

All Answers

VinayVinay (Salesforce Developers) 
Hi Jiahao,

You can change data type to auto number of CNO/RNO__c if you do not want to change create new auto number field and use a formula to populate new field value to CNO/RNO__c.

You can also use workflow field update.

Thanks,
Jiahao Zheng 33Jiahao Zheng 33
Hi Vinay! Sorry I should've addressed the use case better. So the client wants to generate random 6 digit number whenever he creates a new Account object. Is that something we could do using the auto number field? Thank you very much! 
VinayVinay (Salesforce Developers) 
You can create account record not an account object.  You can generate random number once you set the start value.  Eg. Salesforce-0001,  Salesforce-0002 etc based on your prefix or only number.

User-added image

Let me know if you have any additional questions

Please mark as Best Answer if above information was helpful so that it can help others in the future.

Thanks,
This was selected as the best answer