MSCRM Infinite Loop setting for Plugins
I got an issue today where a customer action triggered this error message "This workflow job was canceled because the workflow that started it included an infinite loop..."
The weird thing being that only plugins were involved in the action; so I did a quick trace of the plugins execution depth and sure it went up to 8; which is the maximum default depth authorized for workflows in a one hour period; just before the exception triggered.
This particular customer scenario needed more than a depth of 8 cascading calls (not much more, but a bit more nevertheless). The documentation was silent about the platform plugin infinite loop settings but as the error message stated 'workflows', I did a quick check with reflector in the Microsoft.Crm.dll and the same error message is triggered on the Plugin Execute method when the maximum depth is reached.
Now, the good news is that the workflows default setting seems to be also used for the plugins pipeline and this setting is well documented.
So I just had to increment the maximum depth setting for workflows to solve the issue; unfortunately this only works on a on premise deployment as those settings are not updatable for online deployment (which makes sense when you think of it)
For CRM 2011
On the CRM Deployment Server, start Powershell and then run the following commands :
Add-PSSnapin Microsoft.Crm.PowerShell
$setting = Get-CrmSetting WorkflowSettings
$setting.MaxDepth=n (n being the new Maximum Depth you want to set)
Set-CrmSetting $setting
You can find more information on PowerShell for MSCRM at this link http://msdn.microsoft.com/en-us/library/gg328563.aspx
For CRM 4.0
Download the deployment config tools from http://msdn.microsoft.com/en-us/library/gg328563.aspx (direct link here)
Run the following statement:
microsoft.crm.deploymentconfigtool.exe workflowsettings update -maximumdepth:n (n being the new Maximum Depth you want to set)