Skip to content
Community Question

How can developers prevent plug-in recursion and unintended repeated execution in Dataverse?

Share knowledge. Learn from experts. Build together.

Question

Dataverse plug-ins can unintentionally execute multiple times when plug-in logic updates records or triggers additional pipeline events. This discussion explores practical techniques for controlling recursion and unnecessary executions, including understanding execution depth, filtering attributes, execution stages, entity images and avoiding unnecessary updates. It also highlights why simply checking Depth should not become a substitute for designing the plug-in correctly. An important topic for Dynamics 365 CE developers who want to build predictable, performant and maintainable server-side business logic.
62 Views Community Discussion

Answers

Dataverse plug-ins can unintentionally execute multiple times when one operation triggers another update that satisfies the same plug-in registration. This can result in recursion, unnecessary processing, performance issues, or even unexpected data changes.

A strong prevention strategy starts with precise plug-in registration. For Update messages, configure filtering attributes so the plug-in executes only when relevant columns are included in the update request. Microsoft specifically recommends filtering attributes for Update registrations.

Developers should also examine the plug-in execution pipeline, avoid unnecessary self-updates, and design business logic so that one operation does not repeatedly trigger itself. Execution context information such as Depth can help identify repeated execution, but it should not become the only mechanism for preventing bad design.

The deeper principle is control the trigger conditions and minimise unnecessary writes. Good plug-in architecture prevents recursion through registration and design rather than simply detecting recursion after it occurs.

Your Answer

Connect