Note about Post / Mentions - internal email client question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ShulzR
    Member
    • Aug 2022
    • 32

    Note about Post / Mentions - internal email client question

    Hi,
    Users have the option selected in the preferences: Email notifications about mentions in posts​.
    They receive notifications to external e-mail clients, but the internal EspoCRM e-mail client does not have these e-mails. Why?
    Is it possible somehow email about the post/mentions were also visible in the internal e-mail client?​
  • ShulzR
    Member
    • Aug 2022
    • 32

    #2
    I tried to do it with workflow but {{post}} doesn't work :/
    Attached Files

    Comment

    • lazovic
      Super Moderator
      • Jan 2022
      • 810

      #3
      ShulzR,

      Please try to create a Workflow with Entity Type Note and Trigger Type After record created.
      Select the Action Execute Formula Script and paste this formula:
      Code:
      $crmURL = 'https://test.espocloud.com/#'; // change it to your instance URL with adding # character
      
      $parentId = entity\attribute('parentId');
      $parentName = entity\attribute('parentName');
      $parentType = entity\attribute('parentType');
      $post = entity\attribute('post');
      
      $createdByName = entity\attribute('createdBy.name');
      
      $usernameCatch = string\match($post, '/@\S*/');
      $username = string\substring($usernameCatch, 1);
      $usernameId = record\findOne('User', 'createdAt', 'desc', 'userName=', $username);
      
      $userEmailAddress = record\attribute('User', $usernameId, 'emailAddress');
      
      $parentEntityAddress = string\concatenate($crmURL, $parentType, '/view/', $parentId);
      
      $body = string\concatenate('You have been mentioned by the user ', $createdByName, '. Post: ', $post, '. See in CRM: ', $parentEntityAddress);
      
      ifThen(
      string\contains($post, $usernameCatch),
      $id = record\create(
      'Email',
      'to', $userEmailAddress,
      'subject', '[CRM] Mentions',
      'body', $body,
      'isHtml', true,
      'status', 'Draft')
      );
      
      ext\email\send($id);

      You can change the body of email in the $body variable. But keep in mind that you can't do formatting this way (paragraphs, bold type, etc.).
      Last edited by lazovic; 09-30-2022, 11:25 AM.

      Comment

      • ShulzR
        Member
        • Aug 2022
        • 32

        #4
        Thank You lazovic for replay!
        Unfortunately, the following error appears in the logs:​
        PHP Code:
        ERROR: Workflow[63244b811905e06cb]: Action failed [executeFormula] with cid [0], details: function: ext\email\send, index: 1, should be: string. [] []
        

        Comment


        • lazovic
          lazovic commented
          Editing a comment
          It is very strange.
          Please tell me which version of EspoCRM and Advanced Pack are you using?
      • ShulzR
        Member
        • Aug 2022
        • 32

        #5
        EspoCRM v 6.1.4, Advanced Pack 2.7.0​

        Comment

        • lazovic
          Super Moderator
          • Jan 2022
          • 810

          #6
          ShulzR,

          Could you please show what your Workflow looks like in its entirety, as well as the full formula that is written in the Execute Formula Script Action?

          Comment

          Working...