populating a relate field in a before_save logic hook

I’ve added a ā€˜relate’ field in the Project module in which I want to store the id of a specific account record.

I’ve got this function that I’m calling before_save:

function Project_LinkAccount($bean, $event, $arguments) {
$GLOBALS[ā€˜log’]->setLevel(ā€˜debug’);
$bean->load_relationship(ā€˜accounts’);
$account_id = implode($bean->accounts->get());
$GLOBALS[ā€˜log’]->debug(ā€œaccount_id value is: $account_idā€);
if ( ! empty( $account_id ) ) {
$bean->account_c = $account_id;
$GLOBALS[ā€˜log’]->debug("account_c set to: " . $bean->account_c);
}
$GLOBALS[ā€˜log’]->setLevel(ā€˜fatal’);
}

when it executes I get the following logged:

Fri Mar 31 13:35:35 2017 [508][6403d81d-0a9d-e6d7-cdc6-56d70932a82a][DEBUG] SugarBean[Project].load_relationships, Loading relationship (accounts).
Fri Mar 31 13:35:35 2017 [508][6403d81d-0a9d-e6d7-cdc6-56d70932a82a][DEBUG] account_id value is: a4183b33-5b43-0439-e6e9-58c032ea9b98
Fri Mar 31 13:35:35 2017 [508][6403d81d-0a9d-e6d7-cdc6-56d70932a82a][DEBUG] account_c set to: a4183b33-5b43-0439-e6e9-58c032ea9b98

my problem is that the id of the account record is not saved. I’m assuming that there is some magic that I’m missing in order to populate the ā€˜relate’ field.