Hi,
I need to update contacts teams when we update their account teams.(which the contacts linked to)
How to get the list of contact ids an account has?
I tried like this in beforeSave.
$idList=$entity->getContactIdList();
foreach ($idList as $id){
$contact=$this->getEntityManager()->getEntity('Contact', $id);
$contact->set('teamsIds', $entity->getTeamIdList());
$contact->set('teamsNames', $entity->get('teamsNames'));
}
And in Account.php
public function getTeamIdList() {
if (!$this->has('teamsIds')) {
$this->loadLinkMultipleField('teams');
}
return $this->get('teamsIds');
}
public function getContactIdList() {
if (!$this->has('contactsIds')) {
$this->loadLinkMultipleField('contacts');
}
return $this->get('contactsIds');
}
Not working.
Please help.
I need to update contacts teams when we update their account teams.(which the contacts linked to)
How to get the list of contact ids an account has?
I tried like this in beforeSave.
$idList=$entity->getContactIdList();
foreach ($idList as $id){
$contact=$this->getEntityManager()->getEntity('Contact', $id);
$contact->set('teamsIds', $entity->getTeamIdList());
$contact->set('teamsNames', $entity->get('teamsNames'));
}
And in Account.php
public function getTeamIdList() {
if (!$this->has('teamsIds')) {
$this->loadLinkMultipleField('teams');
}
return $this->get('teamsIds');
}
public function getContactIdList() {
if (!$this->has('contactsIds')) {
$this->loadLinkMultipleField('contacts');
}
return $this->get('contactsIds');
}
Not working.
Please help.
Comment