Announcement

Collapse
No announcement yet.

formular email send not

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

  • formular email send not

    hello

    this work


    $id = record\create( 'Email', 'from', 'from-address@test.com', 'to', 'to-address@test.com', 'subject', 'Test from formula', 'body', 'Hi,\n\nThis is a test.', 'isHtml', false, 'status', 'Sending' ); ext\email\send($id);

    this work not


    $id = record\create(
    'Email',
    'from', 'support@cvu-berlin.de',
    'to', assignedUser.emailAddress,
    'subject', 'Test from formula',
    'body', 'Hi Peter,\n\nThis is a test.',
    'isHtml', false,
    'status', 'Sending'
    );
    ext\email\send($id);


    the assigned user should receive a mail.
    does anyone have an idea?
    peter

  • #2
    Hi,
    i think you need first find "assignedUser".. then find "emailAddress" :
    like :

    $assignedUserId = entity\attribute('assignedUserId')
    $emailAddress = record\attribute('User', $assignedUserId, 'emailAddress');

    to try (maybe in 2 time, first find assignedUser .. then find emailAddress)
    Last edited by item; 03-25-2022, 11:35 AM.

    Comment


    • #3
      Hello Peter,

      Please try this formula:

      Code:
      $assignedUserId = entity\attribute('assignedUserId');
      $assignedUserEmail = record\attribute('User', $assignedUserId, 'emailAddress');
      
      $id = record\create(
      'Email',
      'from', 'support@cvu-berlin.de',
      'to', $assignedUserEmail,
      'subject', 'Test from formula',
      'body', 'Hi Peter,\n\nThis is a test.',
      'isHtml', false,
      'status', 'Sending'
      );
      
      ext\email\send($id);

      Comment


      • #4
        Thank you to everyone who replied.
        I have simply
        'parentId', entity\attribute ('id'),
        from the example in the doc
        and now it works.
        The next step was to include an email template as per the documentation
        ext\email\applyTemplate($emailId, '12345679');
        This also works. Unfortunately, the variables from the dataset are not inserted into the template, i.e. the template does not have access to the parent dataset.
        Is this already possible in Espo 6.5.3?

        Comment

        Working...
        X