I need your help or suggestions in create custom module where I need send an email to user and admin if there is any status change in ticket or field values changes (such as description updated) in existing database.

  • Things I know: drupal_mail() function helps me to send email and HOOK_mail() helps me to format the mail structure and I need to implement these in '<module_name>.module' file.

But,i need your suggestions in implementation for checking the data values of specific field(such as description field). if values are change, mail need to trigged.

I am open for any suggestions. Thank you

1 Answer 1


If I understand your question correctly, you need to know what has been changed when an entity is updated. You can do that using hook_entity_update() or hook_ENTITY_TYPE_update():

This hook runs once the entity storage has been updated. Note that hook implementations may not alter the stored entity data. Get the original entity object from $entity->original.

For instance, assuming you want to know whether the field_description has been changed when a node gets updated, you can do that in your .module file:

 * Implements hook_ENTITY_TYPE_update() for node entities.
function <module-name>_node_update(NodeInterface $node) {
  if ($node->get('field_description')->value !== $node->original->get('field_description')->value) {
    // Apply the logic when the description field changes.

where <module-name> is the name of your module.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.