I am trying to create a hook for the beforeSave event on Tasks so that it spawns multiple, new tasks for a particular task.
Below are the 'barebones' of it but I am just struggling here!!!
Help & thanks in advance:-)
Scott
<?php
namespace Espo\Custom\Hooks\Task;
use Espo\ORM\Entity;
class Task extends \Espo\Core\Hooks\Base
{
public function beforeSave(Entity $entity, array $options = array())
{
if($entity->isNew())
{
$entityManager = $this->getEntityManager();
$newhire = $entityManager->getEntity('Task');
$newhire->set('name', 'Test new hire task1');
$entityManager->saveEntity($newhire);
return;
}
}
}
Below are the 'barebones' of it but I am just struggling here!!!
Help & thanks in advance:-)
Scott
<?php
namespace Espo\Custom\Hooks\Task;
use Espo\ORM\Entity;
class Task extends \Espo\Core\Hooks\Base
{
public function beforeSave(Entity $entity, array $options = array())
{
if($entity->isNew())
{
$entityManager = $this->getEntityManager();
$newhire = $entityManager->getEntity('Task');
$newhire->set('name', 'Test new hire task1');
$entityManager->saveEntity($newhire);
return;
}
}
}
Comment