在使用Studio的Meetings模块中,我添加了一个与一对多的帐户模块的关系。当我保存会议条目并使用帐户添加相关条目时,相关帐户的详细信息未显示在帐户子面板中。我使用的是最新版本的SugarCRM。
提前致谢。
答案 0 :(得分:1)
创建一个逻辑钩子以实现所需的结果:
定制/模块/会议/ logic_hooks.php
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'Set Account relationship', 'custom/modules/Meetings/AccountRelationshipHook.php', 'AccountRelationshipHook', 'setAccountRelationship');
$hook_array['before_delete'] = Array();
$hook_array['before_delete'][] = Array(1, 'Remove Account relationship', 'custom/modules/Meetings/AccountRelationshipHook.php', 'AccountRelationshipHook', 'deleteAccountRelationship');
然后在您的逻辑钩子中创建方法以使用新定义的关系'meetings_accounts'(或任何您命名的关系)并添加或删除帐户记录。由于它是一对多,因此您需要确保每个会议记录只有一个帐户。此外,为了保持整洁,删除会议时也会通过deleteAccountRelationship()方法删除记录的关系。
定制/模块/会议/ AccountRelationshipHook.php
class AccountRelationshipHook {
public function setAccountRelationship(&$bean, $event, $arguments) {
if ($bean->parent_type == 'Accounts') {
$bean->load_relationship('meetings_accounts');
if ($bean->parent_id != $bean->fetched_row['parent_id']) {
$bean->meetings_accounts->delete($bean->id, $bean->fetched_row['parent_id']);
}
$bean->meetings_accounts->add($bean->parent_id);
}
}
public function deleteAccountRelationship(&$bean, $event, $arguments) {
if ($bean->parent_type == 'Accounts') {
$bean->load_relationship('meetings_accounts');
$bean->meetings_accounts->delete($bean->id, $bean->parent_id);
}
}
}