0
votes

I have a workflow in Microsoft CRM 2011 that fires on a certain field change.
When this workflow fires, it will first check the boolean value of flag: if the value is yes then set it to no otherwise if flag value is no then create another "XYZ" entity.

My problem is: when I change flag value to no it again fires and create another entity "XYZ".

1

1 Answers

0
votes

It's happening because your plugin is looping infinitely, as it triggers itself over and over again.

You can prevent the loop using the IExecutionContext.Depth property

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

IPluginExecutionContext context = IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

if (context.Depth > 1) { return; }

This will cancel your plugin when your depth is deeper than 1.