Answers.Body: <p>I am not 100% sure, but there are some peculiarities within the case process. One of them is that the complete set of data is saved at the end of the overall case transaction, and for CiviCRM purposes it is a rather long transaction. And if there is either an error or a cancel somewhere during the whole sequence it might be that a record was created in civicrm_case (allocating an ID) which is then removed later on, but the ID is gone. </p>
  
  <p>If you look at the table it does mention that ID is auto increment, meaning it is sequencing. As a test you might want to try creating a case but then not completing the open case activity and see if it allocated a case ID (if you catch my drift...) We certainly encountered some un-characteristic stuff when creating custom extensions for CiviCase :-)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-16T12:04:40.747Z
Answers.Text: Thanks Erik - that certainly sounds plausible. In this scenario the cases are generally being created from a few webforms. The forms are pretty complex (multi-page, lots of conditionals and lots of fields), so that might be contributing to the issue. I'll try to test as you suggest.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-16T12:13:13.583Z
Answers.Text: I recognize the scenario, we have quite a few of those at one of our customers too!
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-16T11:55:10.240Z
Answers.LastActivityDate: 2016-08-16T11:55:10.240Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>I've assumed that CiviCRM simply allocates the next available Case ID number when a new case is created. Certainly it has always looked that way. However, on one site I work with where cases are used extensively, we are seeing case numbering that suggests something else is happening:</p>
  
  <p>Case ID numbers started at 1 and run pretty consistently up to 86, then a jump to 164, then a second jump from 167 to 249, then straight to 332, then from 372 to 617, from 620 to 747, and from 766 to 1059. (Taken from the civicrm_case table in the DB).</p>
  
  <p>On another site, with a comparable number of cases, the case IDs run from 1 up to about 255 (last time I checked) without a break.</p>
  
  <p>I'm concerned that the non-sequential numbering might be indicative of a problem.</p>
  
  <p>What might be happening to make CiviCase create non-sequential case ID numbers?</p>
  
Tags: <civicase>
Title: How are CiviCase Case ID numbers generated?
ThreadText: # How are CiviCase Case ID numbers generated?
  
  (Asked by: username_0 on 2016-08-16)
  
  I've assumed that CiviCRM simply allocates the next available Case ID number when a new case is created. Certainly it has always looked that way. However, on one site I work with where cases are used extensively, we are seeing case numbering that suggests something else is happening:
  
  Case ID numbers started at 1 and run pretty consistently up to 86, then a jump to 164, then a second jump from 167 to 249, then straight to 332, then from 372 to 617, from 620 to 747, and from 766 to 1059. (Taken from the civicrm\_case table in the DB).
  
  On another site, with a comparable number of cases, the case IDs run from 1 up to about 255 (last time I checked) without a break.
  
  I'm concerned that the non-sequential numbering might be indicative of a problem.
  
  What might be happening to make CiviCase create non-sequential case ID numbers?
  
  **Tags:** civicase
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-08-16. Score: 2
  
  I am not 100% sure, but there are some peculiarities within the case process. One of them is that the complete set of data is saved at the end of the overall case transaction, and for CiviCRM purposes it is a rather long transaction. And if there is either an error or a cancel somewhere during the whole sequence it might be that a record was created in civicrm\_case (allocating an ID) which is then removed later on, but the ID is gone.
  
  If you look at the table it does mention that ID is auto increment, meaning it is sequencing. As a test you might want to try creating a case but then not completing the open case activity and see if it allocated a case ID (if you catch my drift...) We certainly encountered some un-characteristic stuff when creating custom extensions for CiviCase :-)
  
  > **Comments:**
  > **username_0**: Thanks Erik - that certainly sounds plausible. In this scenario the cases are generally being created from a few webforms. The forms are pretty complex (multi-page, lots of conditionals and lots of fields), so that might be contributing to the issue. I'll try to test as you suggest.  
  > **username_1**: I recognize the scenario, we have quite a few of those at one of our customers too!  
  
  ---
  
  