Dear all,
I built a custom Module which should represent better our company structure in CRM. The repository of these data are in an external database. Out from there I built an API interface witch brings the data to CRM. I have experience on this, because we us this for other occasions as well. As I don't know the relation of each record at the moment of the selection in the external database, I decided to relate the records witch resides in CRM at the moment of the import with a logic hook.
This works very well for single POST calls. Because of the data amount I would like to import the data with bulk-calls. Also this works fine until the logic hook should do his job. In that case the hook triggers only once.
Does anybody out there know something about this issue? I tried before_ and after_save hooks. We're on SUGAR 11
This is how my hook looks like
class pskHook {
// before Save Hooks
public function getAccount ($bean, $event, $arguments) {
$psk = $bean->mg_psk_no_c;
$accounts = BeanFactory::newBean('Accounts');
$query = new SugarQuery();
$query->select(array('id', 'mg_psk_c'));
$query->from($accounts, array('team_security' => true));
$query->where()->equals('mg_psk_c', $psk);
$account_list = $query->execute();
if ( $account_list != null ) {
$rel_name = 'psk_accounts_1';
if($bean->load_relationship($rel_name)){
foreach ($account_list as $acct) {
$bean->$rel_name->add($acct['id']);
}
}
}
}
}
Any inputs are really appreciated. Thank you very much to share your thoughts.
Rene