How to notify a given user from within a Hook class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    How to notify a given user from within a Hook class

    i have some custom hooks for account entity and it involves finding related entities, e.g i have a custom entity called Contract (One Account Has Many Contracts) in my hook i try to find all related contracts for the account but i want to notify the user if no contract has been found. i would just like to use built in notification to notify the user. how can i achieve this? anyone has used the notification before?

    yuri can you please help. how can i use the notification within a php class (Hooks)?

    Thanks
    Rabii
    Web Dev
  • yuri
    Member
    • Mar 2014
    • 8452

    #2
    I used github search: https://github.com/espocrm/espocrm/s...q=Notification. And found https://github.com/espocrm/espocrm/b...ocess.php#L114

    PHP Code:
    
    use Espo\Entities\Notification;
    
    // ...
    
    $notification = $this->entityManager->getNewEntity(Notification::ENTITY_TYPE);
    
    $notification
        ->setType(Notification::TYPE_MESSAGE)
        ->setMessage($message)
        ->setUserId($userId);
    
    $this->entityManager->saveEntity($notification); 
    
    Last edited by yuri; 04-14-2022, 05:56 PM.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #3
      Many thanks

      i will try it out.

      best regards,
      Rabii
      Web Dev

      Comment

      Working...