SharePoint Designer 2010 - errors were found when compiling the workflow


⛔️ Problem

If you have a LARGE (even with just a few Approval processes) SharePoint Designer 2010 workflow, you may come across an error stating that the workflow cannot be published with message "Errors were found when compiling the workflow. The workflow files were saved but cannot be run. Unexpected error on server associating the workflow.".

This error keeps popping whenever you try to publish the workflow.

This error is known with SharePoint 2010 workflows, but can occur for other SharePoint versions as well.

As a developer, "Unexpected Error" is of no use for troubleshooting with SharePoint. So how do we go about?


SharePoint Errors were found when compiling the workflow
SharePoint Errors were found when compiling the workflow

⚡️ Reason

The problem is caused by the large number of Types that are created during workflow compilation, for workflows with many local workflow variables.
It is more common for workflows with multiple Approval Process actions, as each reconfigured Approval Process Action comes with a large set of local variables, for the different configurable property of the Approval Process.

Prior to the February 2011 CU, limits on the complexity of the workflow definition were enforced by the Microsoft .NET 3.0 workflow compiler. With the February 2011 CU, SharePoint uses the SPWebApplication UserDefinedWorkflowMaximumComplexity property to enforce a maximum number of Types in the workflow definition, and prevent compilation in these cases.


⛏️ Fix

Make sure the February 2011 CU is installed.
This will make available the UserDefinedWorkflowMaximumComplexity property.

By installing a CU that includes the server February 2011 CU, SharePoint administrators are now able to prevent compilation of workflows whose compilation would affect the performance of the farm. The default value of the property is 7000, but can be changed based on the needs and profile of the SharePoint farm.


The following PowerShell (SharePoint Management Shell - Run as Administrator) script can be used to adjust the value per SPWebApplication -

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$new_limit = XXXX (Set the limit here as a number);
$webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup("http://WebAppURL")
$webapp.UserDefinedWorkflowMaximumComplexity = $new_limit
$webapp.Update()

Try publishing the workflow now, will get through! - but takes some time due to heavy workflow (heavy for SharePoint 2010 Designer).


✔️ Tip

For large workflows, try to restructure and either have more reusable pieces, or break out into smaller individual small workflows.

Check if you have multiple versions of the same workflow and older items attached to it, remove older versions of the workflow if required after completing the in progress ones.



Have Questions? Post them here!
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap