Uncategorized

Using CorrelationId to avoid Recursion in CRM Plugins

Recently we had a scenario where we had to avoid the recursion occurring in CRM Plugin due to update of a field through same plugin.

Checking Depth would have helped to avoid this but we had some scenarios where the Depth check won’t work.

So we used the below approach to handle this scenario:

There is a property of IExecutionContext named CorrelationId which stores the GUID for tracking plug-in or custom workflow activity execution.

For more details click here.

We had a class level variable which stored the value of context.CorrelationId.

And before we proceeded the further logic we checked if the value stored in variable is same as context.CorrelationId then only proceed further else return.

Hope this helps!!

 

Leave a comment