3

I'm looking for the formula used by Salesforce on Data Type: Auto Number fields.

I assumed it was sequential (increases by 1 from the last number generated), but according to our data, it doesn't seem true:

Record created 7:32 AM = 0003288395; Record created 9:06 AM = 0003289295. An hour an a half later and the number is 900 higher. According to a report of all records created and sorted by this number field, there are no numbers in between them unless 900 records were deleted - which I confirmed is not the case in our Recycle Bin.

2 Answers 2

3

If you run test methods, and don't opt to preserve sequencing (it's in the test running page under the options button), any tests you run will cause gaps. Also, failed transactions can cause gaps unless you enable the anti-gap function available by contacting support.

4
  • Thanks, again, I can confirm no test ran during this time period. By failed transaction, I'm assuming you mean a failure to insert?
    – zainogj
    Commented Jul 18, 2014 at 15:45
  • 1
    There may be failed transactions that caused the gap. Do you have any integrations that may have been loading data, or triggers that may have failed, etc?
    – sfdcfox
    Commented Jul 18, 2014 at 15:47
  • Got it, absolutely. I'll dig in a little more.
    – zainogj
    Commented Jul 18, 2014 at 15:48
  • That seems to be true. I feel like a fool for never noticing that. We've had a batch process which runs (not even sure how long it's been active) which has failures in it. Thanks again.
    – zainogj
    Commented Jul 18, 2014 at 16:02
3

Autonumbers are also used up in unit tests, although you can turn on a setting in tests to disable this.

This is under setup | develop | apex test execution | options

enter image description here

1
  • Thanks, that does appear useful and good to know, but it doesn't seem like that resolves my issue. Just like the recycle bin, I don't know of any APEX test executions that occurred between those record entries. Even looking at our APEX Test results, I'm not seeing any tests during this time period.
    – zainogj
    Commented Jul 18, 2014 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .