Closed pasres closed 6 months ago
You should not have two triggers on the same SObject calling MetadataTriggerHandler().run()
.
The framework is specifically built to handle the orchestration of all trigger logic from one injection point.
In the case of a package trigger, there should only ever be one trigger on the SObject which would be included int he package itself. Clients can then implement the trigger action interfaces and add new logic via custom metadata and retain the single injection point.
Thanks for getting back with the info. We also came to the conclusion that it would be best to package the triggers toghether with the framework. Additionally we implemented it so that the framework entrypoint is not "Namespaceaccessible", so any potential second trigger from another package can't actually call it.
Disclaimer: I know the framework works as intended, so this is more of an open question. I'll still put it in the form of an issue. Please feel free to just dismiss and close it if you feel this is beyond the scope of the framework. Thanks in advance!
Expected Behavior
Actual Behavior
Steps to Reproduce the Problem
Specifications
Background: We are developing 2GP managed packages. We would like to package the framework (think of it as a commons/utilities package) and have other packages depend on it. This could lead to multiple triggers on the same object calling the framework entry point (MetadataTriggerHandler) thus running triggers multiple times. We are now wondering how to best prevent this (besides manual code review) - if that's even possible. I understand the framework was probably not created with this kind of use case in mind, but maybe it is something worth considering.