5

Just as the title asks, how do I set the startpoint for an autonumber after field creation? The field is an external Id and to avoid conflict with the external system, I need to move the id up a few numbers.

  • even if you set an arbitrarily high number, is it not conceivable that the numbers might overlap at some point? Or is the creation of the object solely driven by the existence of the external record? – ebt Aug 20 '12 at 15:47
  • @ebt: The data in the external system is setup like so: [1...OPEN...10][11...FILLED...20][21...OPEN] where there is a chunk of occupied Ids. I can't say why the data got into this state. – Bob Roberts Aug 20 '12 at 15:55
14

You can convert the field type to text, then convert it back to auto number. When you convert it back, you'll have the option to set the starting number again. I might do this after hours if there is a danger of a record being created while you're doing the field conversion.

https://help.salesforce.com/HTViewSolution?id=000005195&language=en_US

  • Note that this isn't possible for managed auto-number fields, where there's no way currently to force a specific value, since they can't be converted to text. – ca_peterson Oct 16 '13 at 20:17
2

Changing the field type is a good idea. Alternately, if you're only going to move the auto-number up by a few numbers or even a few tens of numbers, you could insert some records and delete them. Crude but effective.

  • 1
    This is the only time I don't mind that tests increment auto-number fields. If you can't or don't want to change the field type, you can run a test method that just inserts the number of records you need the auto-number moved up by. Then you don't actually have to create and delete records. – Rob Scott Aug 20 '12 at 21:07
  • I was tempted to do this but there is a complex object hierarchy that would also have to be created. – Bob Roberts Aug 21 '12 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.