Send custom email when a comment is written in the Stream of a custom entity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rafael Cardero
    Junior Member
    • Nov 2020
    • 3

    Send custom email when a comment is written in the Stream of a custom entity

    I created a custom entity named "Project". Each time a comment is written in the Stream section of a project, I need to send the comment via email to the comment author AND to the target account of the project.

    The email subject must be structured as follows: "[<Project_ID>] New comment on <Project_Name>". Ex: [123] New comment on Sample Project.

    Does EspoCRM allow to solve a problem like this? If true, please provide guidance, useful docs, etc.
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Hello,

    stream => note entity
    so you can make a beforeSave hook

    PHP Code:
    public function beforeSave(Entity $entity, array $options = array())
    {
    $post = $entity->get('post');
    
    if($entity->get('type') == 'Post' && $entity->isNew() && $entity->get('parentType') == 'Project') {
    $ent = $this->entityManager->getEntity($entity->get('parentType'), $entity->get('parentId'));
    // 
    // SEND EMAIL. search on forum how send email..
    } 
    
    Maybe possible with Workflows.. not checked
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • Maximus
      Senior Member
      • Nov 2018
      • 2731

      #3
      Hi,
      W/o codding you can create Workflow for the Note entity and try to build such logic https://docs.espocrm.com/administration/workflows/.

      Comment

      Working...