$bean->emailAddress->addAddress is not working, and $sea->addAddress REMOVES all other addresses

I am writing an API to change an email address on a contact.
I don't want to remove the old address, just add the new one as primary on the Contact bean.

I used the documented addAddress ( support.sugarcrm.com/.../ )

Fullscreen
1
2
$contactBean->emailAddress->addAddress($new_email_address, true);
$contactBean->save();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

But this won't even add the new address to Contact at all. There are no errors in the logs, I verified that the contactBean is a valid Bean, and that the $new_email_address is a valid address. I checked the parameters for the addAddress function and I verified that the function is being called.

What's worse

Fullscreen
1
2
3
4
5
$sea = new SugarEmailAddress();
$sea->addAddress($email_address,true);
//do some checks...
//add the email address to the Contact $bean
$sea->save($bean->id, 'Contacts');
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Adds the new address but DELETES all the others!

Has something changed in v11.0.1 (on site Professional) that I'm not aware of?

Thank you,
Francesca

1 2