Answers.Body: <p>Converted comment to answer:</p>
  <p>I think it's always been like this? And for editing an existing one it's not -1 it's the autoincrement id in the customvalue table.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-15T21:37:50.843Z
Answers.LastActivityDate: 2021-06-15T21:37:50.843Z
Answers.UserDisplayName: Demerit
Body: <p>On my latest Civi 5.37.2 the params array passed to <code>hook_civicrm_pre</code> looks like:</p>
  <pre><code>Array
  (
      [hidden_custom] =&gt; 1
      [hidden_custom_group_count] =&gt; Array
          (
              [] =&gt; 1
          )
      [custom_395_-1] =&gt;          &lt;-------- Spooky appdx
      [custom_463_-1] =&gt; 1000     &lt;-------- Spooky appdx
   [...]
  </code></pre>
  <p>This happens when adding a new activity to a case. <code>hook_civicrm_customPre</code> works in other cases but it is <em>not</em> fired here. So it seems, there is no hook to get a sane <code>custom_&lt;fieldid&gt;</code> param prior saving to db.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-15T20:24:19.657Z
Comments.Text: I think it's always been like this? And for editing an existing one it's not `-1` it's the autoincrement id in the customvalue table.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-15T21:03:24.220Z
Comments.Text: Jesus, I should have derived this from my dotnet and other orms development experience. Will you answer?
Comments.UserDisplayName: nielo
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-15T21:38:13.897Z
Comments.Text: He he I thought this was a unique civi thing - maybe not.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-16T08:55:58.000Z
Comments.Text: No, using negative temporary ids is quite common, I think. Thanks a load!
Comments.UserDisplayName: nielo
Tags: <custom-fields><hooks><core>
Title: custom fields in hook_civicrm_pre' $params have an extra "_-1" suffix
ThreadText: # custom fields in hook_civicrm_pre' $params have an extra "_-1" suffix
  
  (Asked by: username_0 on 2021-06-15)
  
  On my latest Civi 5.37.2 the params array passed to hook_civicrm_pre looks like:
  Array
  (
      [hidden_custom] => 1
      [hidden_custom_group_count] => Array
          (
              [] => 1
          )
      [custom_395_-1] =>          <-------- Spooky appdx
      [custom_463_-1] => 1000     <-------- Spooky appdx
   [...]
  
  This happens when adding a new activity to a case. hook_civicrm_customPre works in other cases but it is not fired here. So it seems, there is no hook to get a sane custom_ param prior saving to db.
  
  **Tags:** custom-fields, hooks, core
  
  > **Comments:**
  > **username_1**: I think it's always been like this? And for editing an existing one it's not `-1` it's the autoincrement id in the customvalue table.  
  > **username_0**: Jesus, I should have derived this from my dotnet and other orms development experience. Will you answer?  
  > **username_1**: He he I thought this was a unique civi thing - maybe not.  
  > **username_0**: No, using negative temporary ids is quite common, I think. Thanks a load!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-15. Score: 1 | Accepted answer
  
  Converted comment to answer:
  
  I think it's always been like this? And for editing an existing one it's not -1 it's the autoincrement id in the customvalue table.
  
  
  ---
  
  