Account and emailAddressData, beforeSave not triggered

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • giant
    Junior Member
    • Dec 2017
    • 15

    Account and emailAddressData, beforeSave not triggered

    Hello,

    I have a hook for Account entity that updates a field based on it's email addresses using beforeSave method.
    It is working fine when saving Account in full edit mode. But if I use quick save for email addresses only, it is not working.
    I think the beforeSave method is not triggered at all. Is there some way to trigger it or some other method ?

    My hook is located at
    custom/Espo/Custom/Hooks/Account

    And the field is the standard emailAddress
  • giant
    Junior Member
    • Dec 2017
    • 15

    #2
    Okay, actually it is triggered.

    I guess the problem is actually that emaill address changes are not saved yet?

    I use this code to get them:
    $emails = $entityManager->getRepository('EmailAddress')->getEmailAddressData($entity);

    Comment

    • giant
      Junior Member
      • Dec 2017
      • 15

      #3
      I think I found a solution!

      I moved it to from beforeSave to afterSave method and then use this command:
      $this->getEntityManager()->saveEntity($entity, array('skipWorkflow' => true, 'skipHooks' => true));

      Now that makes me wonder if skipAll would be better than these two.

      Comment

      Working...