Announcement

Collapse
No announcement yet.

Problem with sending Email by formula

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with sending Email by formula

    I use the formula ext/applyTemplate. I created a template with some placeholders and this template works, when I choose it sending an email manually. Though by the formula, the placeholders from the entity (case) are not transposed, other placeholders like assignedUser are transposed correctly. The mail itself is sent as desired.
    I don`t see, where I could do something wrong.

  • #2
    Can you share a screenshot of your code maybe will help you spot what is wrong.
    Rabii
    Web Dev

    Comment


    • #3
      Hello,

      here is the formula.

      Code:
      $emailId = record\create(
      'Email',
      'to', 'email@email.com',
      'status', 'Sending',
      'parentId', entity\attribute('id'),
      'parentType', 'Case'
      );
      
      ifThen(
      entity\isNew(),
      ext\email\applyTemplate($emailId, '[template ID]');  (in the code without brackets!)
      ext\email\send($emailId)
      );
      As already written, the template placeholders are present and the template itself works, when used in a normal email (not using formula). And the formula works also, the email is sent and I receive it in the provided inbox, only without transposing the placeholders in that case.​

      Comment


      • rabii
        rabii commented
        Editing a comment
        Yes this wouldn't work as this runs on beforeSave script therefore the case is not yet saved into the DB.

        This would work if you use workflow. (after record created)

      • shalmaxb
        shalmaxb commented
        Editing a comment
        ok meanwhile I also guessed that.

    • #4
      entity is new => no id, no in database
      formula => beforeSave.

      so no fill template my opinion

      Comment


      • #5
        But what I use is the formula from the documentation. The only thing I added was the ifThen(entity\isNew(). Maybe it is because of that. I want to achieve, that, when I save a new record in case, an email will be sent to the admin.

        Perhaps only possible with workflow?

        Comment

        Working...
        X