If I call get_linked_beans method in the after retrive logik hook with N linked beans, it is called 1 + N times (N = amount of related records). For example:
Thank you, but this describes problem with saving. I am not saving. To test I did next steps.
Clean Install CRM
With module builder create new package
With module builder create new module1
With module builder create new module2
With module builder create relationship one-to-many (module1 -> module2)
Create After Retrieve Hook on module 1
Call get_linked_beans(āmodule2ā)
There is 3 calls After Retrieve Hook
New details. No matter how many records in a related entity when I call get_linked_beans, after retrieve hook called 3 times instead of 1. It looks like a bug.
You can try using debug_backtrace or debug_print_backtrace in each of those calls into the hook, to get a view of what the call stack looks like in each of those calls. I am not sure, but this might give you some clues as to which parts of the code are calling into the hook.
So, it seems that the hook is called once for the record, and then once for each ārelateā field in the record. Maybe itās not a bug, it seems to be by design.
The question is: when you are inside the hook, can you distinguish between these calls? Can you find some parameter that you can test, to know which case it is?