AnsweredAssumed Answered

Remove relationship between case and email

Question asked by Autchara Chaiprom on Nov 20, 2017

Hi,

I try to remove relationship between case and email via logic hook 3 ways but not working.

// Email logic hook
// 1
$bean->load_relationship("cases");
$bean->cases->delete($bean->id, $case_id);
$bean->save();

// 2
$c = BeanFactory::newBean('Cases');
$c->load_relationship('emails');
$c->emails->delete($case_id, $bean->id);
$c->save();

// 3
$sql = "UPDATE emails_beans SET deleted = 1 WHERE bean_id = '{$case_id}' AND email_id = '{$bean->id}'";
$GLOBALS['db']->query($sql);

I found that relationship store in emails_beans table and also in emails in parent_id fields.

 

In my problem is there are no relationship store in both place but I still can saw an email in a case.

I guess that I might missing deleted a relationship in some place or some weird part of code.

 

Do you have any idea from this problem?

SugarPro 7.8

Thanks,

M

Outcomes