In addition to Anil's answer, there's a way to do this as part of the deploy so you can avoid the Data Loader and fieldtype swap.
- You will need to manually edit your source file for the object in question (e.g.
You will need to add in two lines as shown below for the autonumber field you desire to deploy and generate values for existing records.
<populateExistingRows>true</populateExistingRows> // add this line
<startingNumber>1</startingNumber> // add this line with desired startVal
- Don't forget to deploy
xxx.profile files to make the field visible to those profiles that care.
- Deploy with your IDE (or ant, sfdx, Gearset or equivalent)
When you deploy to the target org, SFDC will set the starting number to the value of
<startingNumber> and will launch the populate existing records background job.
The reason this works is that tools that use the Metadata API (as of V42) don't have the ability to fetch either of the
startingNumber attributes of the
CustomField metadata object. But they can deploy those values.
You can’t retrieve the starting number of an auto-number field through
Metadata API. To specify a Starting Number while deploying, add a
startingNumber tag for your field to your package.xml file. For