formular email send not

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • peterberlin
    Active Community Member
    • Mar 2015
    • 1004

    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
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #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.
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • lazovic
      Super Moderator
      • Jan 2022
      • 809

      #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

      • peterberlin
        Active Community Member
        • Mar 2015
        • 1004

        #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...