It would be great to have subaccounts. Right now I have a main account with 25 different sub-accounts. It is tough when filtering because I have to add each account individually. It would be a great addition!
Thanks!
Thanks!
namespace Espo\Custom\Hooks\SubAccount;
use Espo\ORM\Entity;
class SubAccountHooks extends \Espo\Core\Hooks\Base
{
public function beforeSave(Entity $entity, array $options=array())
{
if($entity->isNew()) {
// get the parent account object
$parentAccount = $this->getEntityManager()->getEntity('Account',$entity->get('accountId'));
// get the teams to which the parent account is linked
$parentTeamIdList = $parentAccount->getLinkMultipleIdList('teams');
// link those teams to the new sub-account
foreach ($parentTeamIdList as $teamId) {
$this->getEntityManager()->getRepository('SubAccount')->relate($entity, 'teams', $teamId);
}
}
}
}
Comment