Hooks » Get Documents Accounts for Email Template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AGil
    Junior Member
    • Apr 2020
    • 15

    Hooks » Get Documents Accounts for Email Template

    Good morning everyone,

    I have created a workflow that alerts me about changes in some fields of the Document entity.
    In the email template that has the alert message, I was able to put the document file name, the document name, and who made the changes on it but I would like to include also the account name associated with that document.

    The field type that gets the accounts name is "Link Multiple" for that reason I'm trying to create a hook but it always gives me a Bad Server Connexion.

    Someone could help me with this? I don't really know what is going wrong.

    There are some pics trying that maybe can help you to see the problem better.
    Also, this is the code that I'm using:

    <?php
    namespace Espo\Custom\Hooks\Document;

    use Espo\ORM\Document;

    class AccountName extends \Espo\Core\Hooks\Base
    {
    public function afterSave(Entity $entity, array $options = array ())
    {
    if ($entity->isNew() && !$entity->get('accounts')) {
    $entity->set('storageAccountName', 'accounts');
    }
    }
    }

    Best Regards!
Working...