$bean->$link->add is not removing the others

Hi all.

I have an issue where I am adding a relationship on a 1 to Many relationship. So for instance my Lead can only have one Branch linked to it.

However when I am doing $bean->$link->add('newId') the old relationship record is not setting itself to deleted so the new update isn't actually applying, resulting in 2 "live" relationships when there should only be one.

Has anyone else seen this or knows how to fix?

Thank you,

Daniel

  • Fullscreen
    1
    2
    3
    4
    5
    //Load relationships
    $lead->load_relationship('a_branch_leads');
    //Add the new branch to the lead
    //$lead->a_branch_leads->delete($lead->id,$oldID);
    $lead->a_branch_leads->add($newID);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    This is an example