Answers.Body: <p>Don't know if this will help, but at least you can try it. :)</p>
  
  <p>The custom() hook is called after the db write on a custom table, so when the field is writen, you can't know which was the change, so you can't have the id (or at least I think so).</p>
  
  <p>Instead of custom() you can try the pre() hook. Check if the Enjoyment Level has changed (use api to read the field in the db and compare with the $param), and if it had, update the Updated field.</p>
  
  <p>Check this links that posibly can help you:</p>
  
  <p><a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Setting+and+getting+custom+field+values+from+within+hooks" rel="nofollow">Setting and getting custom field values from within hooks</a></p>
  
  <p><a href="https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_pre" rel="nofollow">Hook pre</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-12T11:00:29.120Z
Answers.LastActivityDate: 2016-05-12T11:00:29.120Z
Answers.UserDisplayName: Albert V
Body: <p>Whenever custom data is written to the database you can use the module_custom() hook to determine what most of the parameters written were. However, I've been unable to find the 'id' of the write.</p>
  
  <p>For example lets examine Custom Group Athlete</p>
  
  <h2>Athlete</h2>
  
  <p>Field 1 Label: SportPlayed</p>
  
  <p>Field 1 Type: AlphaNumeric</p>
  
  <p>Field 2 Label: DateStarted</p>
  
  <p>Field 2 Type: Date</p>
  
  <p>Field 3 Label: Enjoyment Level</p>
  
  <p>Field 3 Type: Alphanumeric</p>
  
  <p>Field 4 Label: Updated</p>
  
  <p>Field 4 Type: Date</p>
  
  <p>Now,</p>
  
  <p>Lets ignore any calls that this Custom Group should really be an activity.</p>
  
  <p>Lets assume there are no checks on uniqueness of data answered.</p>
  
  <p>Using the $params variable from the custom() hook I can see the particulars about every field that was writen EXCEPT the ID of the entry(Not the entity ID). </p>
  
  <p>Therefore, if I had The following Data</p>
  
  <pre><code>Sport Played | Date Started | Enjoyment Level | Updated
  -------------------------------------------------------
  Baseball     | 1-1-2012     | High            |
  Baseball     | 1-1-2012     | Low             |
  </code></pre>
  
  <p>and I changed the first entries Enjoyment Level from High to Low, how could I also change the Updated entry to today's date? Remember that, as I understand, I don't actually know which entries are changing values from the $param field. All I know are the values submitted. <strong>I need some way find the id of the entry which is oddly not included in the $param variable</strong> Does anyone have a way to do this? I understand that if values are roughly unique I could run an SQL query to search for all matching parameters and return the ID but that seems overly complicated.</p>
  
Tags: <custom-fields><hooks><mysql>
Title: Multiple Entry Custom Values : Find modified ID?
ThreadText: # Multiple Entry Custom Values : Find modified ID?
  
  (Asked by: username_0 on 2016-05-10)
  
  Whenever custom data is written to the database you can use the module\_custom() hook to determine what most of the parameters written were. However, I've been unable to find the 'id' of the write.
  
  For example lets examine Custom Group Athlete
  
  ## Athlete
  
  Field 1 Label: SportPlayed
  
  Field 1 Type: AlphaNumeric
  
  Field 2 Label: DateStarted
  
  Field 2 Type: Date
  
  Field 3 Label: Enjoyment Level
  
  Field 3 Type: Alphanumeric
  
  Field 4 Label: Updated
  
  Field 4 Type: Date
  
  Now,
  
  Lets ignore any calls that this Custom Group should really be an activity.
  
  Lets assume there are no checks on uniqueness of data answered.
  
  Using the $params variable from the custom() hook I can see the particulars about every field that was writen EXCEPT the ID of the entry(Not the entity ID).
  
  Therefore, if I had The following Data
  
  ```
  Sport Played | Date Started | Enjoyment Level | Updated
  -------------------------------------------------------
  Baseball     | 1-1-2012     | High            |
  Baseball     | 1-1-2012     | Low             |
  
  ```
  
  and I changed the first entries Enjoyment Level from High to Low, how could I also change the Updated entry to today's date? Remember that, as I understand, I don't actually know which entries are changing values from the $param field. All I know are the values submitted. **I need some way find the id of the entry which is oddly not included in the $param variable** Does anyone have a way to do this? I understand that if values are roughly unique I could run an SQL query to search for all matching parameters and return the ID but that seems overly complicated.
  
  **Tags:** custom-fields, hooks, mysql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-12. Score: 3
  
  Don't know if this will help, but at least you can try it. :)
  
  The custom() hook is called after the db write on a custom table, so when the field is writen, you can't know which was the change, so you can't have the id (or at least I think so).
  
  Instead of custom() you can try the pre() hook. Check if the Enjoyment Level has changed (use api to read the field in the db and compare with the $param), and if it had, update the Updated field.
  
  Check this links that posibly can help you:
  
  [Setting and getting custom field values from within hooks](https://wiki.civicrm.org/confluence/display/CRMDOC/Setting+and+getting+custom+field+values+from+within+hooks)
  
  [Hook pre](https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_pre)
  
  
  ---
  
  