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.