AnsweredAssumed Answered

Workaround for the unable to update email addresses problem

Question asked by paperless on Feb 23, 2014
Latest reply on Oct 9, 2014 by Sophie Sophie
The code below provides a temporary solution, until a fix that enables email address updates is applied in 7.x. 
The code works when deployed as a scheduled task. For some reason it does not update the email adddress when deployed as an 'after_save' logic hook.
$sea = new SugarEmailAddress();

// Update the primary email address, 
// by picking up a value previously stored in any other $bean object field (googleplus in this example)
$emailaddress = $bean->googleplus;
//$GLOBALS['log']->fatal("Update Email Address with: {$emailaddress}");

$sea->addAddress($emailaddress, true);   
// Associate the email address with a given module  
$sea->save($bean->id, "Accounts");