Announcement

Collapse
No announcement yet.

Account - Contacts

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Account - Contacts

    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.

  • #2
    Hi,

    I got the contact ids.

    I got till here in account =>beforeSave.


    $contact->set('teamsIds',$entity->getTeamIdList());
    $contact->set('teamsNames',$entity->get('teamsNames'));


    I tried printing this value $contact->getTeamIdList() which is also working, I could see new values in log.

    but it is not saved to database.

    Please help.

    Comment


    • #3
      Sorry, I got it. i had to save contact entity

      Comment

      Working...
      X