+ Start a Discussion

Can any one help me to solve this issue "Auto Increment "

I want auto increment number in account field. format is first four letter from account name next two digits from number. i got it but the problem i have 1000 of accounts i want the number increament upto 99 and again i want to regenerate from 1. but it goes 100, 101, 102...... 


       example:  UPPER(LEFT(Name, 4))+AutoId__c


AutoId__c  i gave display format like this   {00}. i want regenerate from 1 after it reached 99.







Auto number can't be reset on the fly using code. There is a way to reset it, but it involves manual effort. The following article will tell you how to reset the autonumber manually (https://help.salesforce.com/HTViewSolution?id=000005195&language=en_US).


But, if you are looking for an automatic approach, you could have a custom field in account with "0" as starting value. Everytime an account is created, you can have a workflow to increment its value by one, and if the value goes beyond 99, reset the same to 0. Just an idea....have not implemented it though !!





Scott HolmanScott Holman

Create autoincrement field F1 that is solely integer.  Do not display.

Create string field F2 to store your auto generated value and generate the value in the before insert trigger.

In the trigger F2=upper(left(name,4)) + Math.mod(F1,100)