+ Start a Discussion
MayeUPAEPMayeUPAEP 

Restart counter - autonumber field

Is there any way to restart  an autonumber field in a Custom Object??

I can't change the type of my field because I use it in a trigger

Best Answer chosen by Admin (Salesforce Developers) 
Jeremy_nJeremy_n

The only way I know of is to change the field type to Text and change it back to Auto Number. If your trigger uses this field, you'll have to deactivate it first, then reactivate it when the change is done.

 

Jeremy

All Answers

Jeremy_nJeremy_n

The only way I know of is to change the field type to Text and change it back to Auto Number. If your trigger uses this field, you'll have to deactivate it first, then reactivate it when the change is done.

 

Jeremy

This was selected as the best answer
MayeUPAEPMayeUPAEP

Yes you're right it was the only available solution.  So I needed to deactivate all my triggers even my apex code :S, then change the field type and change it back to Auto Number.

 

Thanks a lot

Atif MAtif M
Hi Jeremy,

  If I have package object, and it has got an auto number, Is there any possiblity to reset the counter.

Thanks,
Atif
Rami TaybaRami Tayba
You can hack the metadata of the field and use the tag <startingNumber> with your prefered starting number then deploy the sObject on server.
Exemple:
<fields>
        <fullName>AutoNumber__c</fullName>
        <displayFormat>{000000}</displayFormat>
        <externalId>false</externalId>
        <label>Auto Number</label>
        <trackHistory>false</trackHistory>
        <trackTrending>false</trackTrending>
        <type>AutoNumber</type>
        <startingNumber>15000</startingNumber>
</fields>
Hope this help.
Rami