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


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


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.


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

Hook pre

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.