How to use the Max Execution Depth

Dec 2, 2015 at 7:46 AM
I wanted to understand the use of "Max Execution Depth" field on the actions. How to use it and what are the consequences of a higher number there?

I created a plugin with Max Execution Depth as 1 for an update of an entity. There was an async workflow that would be triggered on this entity and my plugin would not execute but as soon as i increased the depth to 2 my plugin was working.

Please let me know
Coordinator
Dec 3, 2015 at 9:44 AM
Hi DVora,

If you have a plugin triggered on contact update that updates itself the contact (triggers the plugin again), the process can fall into an infinite loop
The execution depth prevents this kind of cases by incrementing a value (depth)
Maximum depth by default is 8 (After that the plugin won't be executed)

Microsoft definition :
Every time a running plug-in or Workflow issues a message request to the Web services that triggers another plug-in or Workflow to execute, the Depth property of the execution context is increased. If the depth property increments to its maximum value within the configured time limit, the platform considers this behavior an infinite loop and further plug-in or Workflow execution is aborted.

Source : https://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.iexecutioncontext.depth.aspx

Hope it helps,

Amine