You can do it using formula, if you wish yo can create a workflow and add condition and triggers and add Script Task to send email using formula, see example of code below (code below use Formula to send the contact an email documents attached to the contact, same thing could be done for your entities:
Code:
$documentId = record\findRelatedOne('Contact', id, 'documents', 'createdAt', 'desc'); $documentName = record\attribute('Document', $documentId, 'name'); $fileId = record\attribute('Document', $documentId, 'fileId'); $attachmentId = record\create('Attachment', 'role', 'Attachment', 'type', record\attribute('Attachment', $fileId, 'type'), 'size', record\attribute('Attachment', $fileId, 'size'), 'global', record\attribute('Attachment', $fileId, 'global'), 'name', record\attribute('Attachment', $fileId, 'name'), 'sourceId', $fileId, 'storage', record\attribute('Attachment', $fileId, 'storage') ); $emailBody = string\concatenate( 'Please find attached required document: ', $documentName, '<br> Cheers'); $emailId = record\create( 'Email', 'to', entity\attribute('emailAddress'), 'subject', 'Required Document', 'body', $emailBody, 'isHtml', true, 'status', 'Sending', 'attachmentsIds', list($attachmentId), 'parentId', id, 'parentType', 'Contact' ); ext\email\send($emailId);
Leave a comment: