Add functionality to "Send message Task"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Laimonas
    Senior Member
    • May 2021
    • 237

    #1

    Add functionality to "Send message Task"

    Hi there,

    We are missing one functionality, when we use workflow and flowchart "Send Message Task" / "Send mail".
    It would be great if there were an additional button "Add field" and a place to write "Formula", which we could use to add additional parameters to the Email that we send. Please see the picture attached.
    Attached Files
  • lazovic
    Super Moderator
    • Jan 2022
    • 1208

    #2
    Hi Laimonas,

    As a temporary solution, I can suggest you to use Execute Formula Script using this formula:
    Code:
    $emailId = record\create(
             'Email',
             'to', $recipientEmail,
             'status', 'Draft',
             'parentId', entity\attribute('id'),
             'parentType', entity\attribute('type')
    );
    
    ext\email\applyTemplate($emailId, 'some-email-template-id');
    ext\email\send($emailId);
    The value of the $recipientEmail variable can also be easily pulled out using formulas. I can help you in this matter if you wish.

    Comment


    • yuri
      yuri commented
      Editing a comment
      I wouldn't call it a temporary solution. It's a good solution.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9639

    #3
    It's already possible to update an email record with Task > Update Created Record. The email entity will be available in the list. Place the task flow element after the Send Message element in the process flow.

    Plus it's possible to use process variables in the email template (see docs).
    Last edited by yuri; 07-14-2022, 03:55 PM.

    Comment

    • SailReal
      Junior Member
      • Jun 2025
      • 12

      #4
      Originally posted by lazovic
      Hi Laimonas,

      As a temporary solution, I can suggest you to use Execute Formula Script using this formula:
      Code:
      $emailId = record\create(
      'Email',
      'to', $recipientEmail,
      'status', 'Draft',
      'parentId', entity\attribute('id'),
      'parentType', entity\attribute('type')
      );
      
      ext\email\applyTemplate($emailId, 'some-email-template-id');
      ext\email\send($emailId);
      The value of the $recipientEmail variable can also be easily pulled out using formulas. I can help you in this matter if you wish.
      This works but unfortunately I can not enable here the `optOutLink` substitution from the template like with the `Send Message Task`. Is there another way to dynamically select the template but also have the `optOutLink` substitution?

      Comment


      • SailReal
        SailReal commented
        Editing a comment
        Okay, there is an option I think. I use `record\create('Email')` again and try to create an `FormulaFunctions` that is able to create the hash via https://github.com/espocrm/espocrm/b...ils/Hasher.php, manually concatenate the url and then I'm able to reuse the existing unsubscribe entry point with email address and hash. Suuuper error prone regarding changes during update but I see no other option.
        Last edited by SailReal; Today, 04:44 PM.

      • SailReal
        SailReal commented
        Editing a comment
        Creating the hash with `FormulaFunctions` works awesome but now I'm stucked with setting a header (`Unsubscribe`) via record\create('Email')...

      • SailReal
        SailReal commented
        Editing a comment
        yuri wouldn't it be possible to pass into the `Send Message Task` a template variable like with the `Attachments Variables` then we would also have the opt-out handling? This would solve all the problems.

        I guess it's common to send an email queue where each stage has different content, and where each template is in a different language depending on the target lead which creates a huge tree when we would moddle it with sticked templates. If we can dynamically adjust the used template, this is just a few lines in a `Script Task`.
    Working...