Announcement

Collapse
No announcement yet.

Problem with formula email send

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

  • Problem with formula email send

    Hello again

    I have a little problem here, maybe just some basic syntax error but I can't figure it out.

    My goal is to make espo auto-send email from my group email account using template '605ce24c7054e5bc4', to linked contact email address, when enum 'serviceState' changes to 'Vybavené' (means Done in my language).

    I made this formula but no matter what status of serviceState enum i choose, everytime it sends template with no link to target entity. Thanks for any advice.


    Code:
    $svcDoneMail = record\create(
         'Email',
         'from', 'noreply@my-group-email.com',
         'to', contact.emailAddress,
         'status', 'Draft',
         'isHtml', true,
         'parentId', servis.Id,
         'parentType', 'Servis'
    );
    
    
    ifThen(entity\isAttributeChanged(serviceState) && serviceState = ('Vybavené'),
         ext\email\applyTemplate($svcDoneMail, '605ce24c7054e5bc4');
         ext\email\send($svcDoneMail)
    );
    Last edited by heligonaut; 03-26-2021, 02:33 PM.

  • #2
    Hello,
    1. entity\isAttributeChanged(serviceState) should be like entity\isAttributeChanged('serviceState'). The quotes arround serviceState were missed.
    2. serviceState = ('Vybavené') should be like serviceState == 'Vybavené'

    > everytime it sends template with no link to target entity

    Perhaps there's some issue in the Email Template?

    Anyway, fix the syntax error first and try again.

    Comment


    • #3
      Maximus thank you very much, now it works and espo sends email only when I choose "Vybavené".

      But the problem with no parent link to target entity still persists. There is probably another syntax error in 'parentId', servis.Id, or 'parentType', 'Servis'.

      If I try to manually send email linked to Servis case with applied template, everything is correct but auto-send just sends raw template

      EDIT: 'parentId', id, now it finally works
      Last edited by heligonaut; 03-26-2021, 07:39 PM.

      Comment


      • telecastg
        telecastg commented
        Editing a comment
        Thanks for posting your solution, will help others facing similar issues.
    Working...
    X