unrelate function on Hook has no effect
Collapse
X
-
if you have the latest version you might try this code below:
PHP Code:$entityManager->getRDBRepository('Account')
->getRelation($account, 'opportunities')
->unrelateById($opportunityId);
-
unrelate function on Hook has no effect
Hi,
Following directions from https://docs.espocrm.com/development/orm/, I do unrelate as follows in a Hook :
I verified by logging that the entities exist and that they are correclty related as I can see the corrects records ids when printing as followsPHP Code:$entityManager
->getRDBRepository('Account')
->getRelation($account, 'opportunities')
->unrelate($opportunity);
Even afterRelate Hooks are triggerred so I assume taht the unrelate is actually executed but for a reason, the entities remain related afterwards.PHP Code:$opportunityCollection = $entityManager
->getRDBRepository('Account')
->getRelation($account, 'opportunities')
->limit(0, 10)
->find();
If I unrelate from frontend GUI in bottom panel, it works fine. But when I unrelate in backend as above, it does not work. Every other statement executed at the same time in my Hook are done properly. I don't have any error logged in backend logs nor in console.
Any help on what direction to search would be highly appreciated as I'm kind of stuck with this issue.
Thanks !Last edited by huscmk; 12-02-2023, 09:42 AM.Tags: None

Leave a comment: