⛔️ 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?
⚡️ 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!
- error CAML Query containing special characters
- [Solved] SharePoint Illegal operation attempted on a registry key that has been marked for deletion
- Trigger Flow on selected Listitem from SharePoint view - create button with JSON column formatting
- SharePoint Excel error - The workbook cannot be opened because it contains the following features that are not supported by Excel in the browser
- Send Email with attachment using SharePoint PowerShell, SMTP server
- How to show or hide columns in SharePoint Online List Library from
- SharePoint excel error - A problem occurred while connecting to the server. If the problem continues, contact your administrator.
- How to get SharePoint Online user details from person or group column using REST API
- How to get SharePoint List Item URL using PowerShell
- How to get the SharePoint Tenant Login URL
- Special character & not working with SharePoint REST API
- How to disable SharePoint subsite creation option for owners
- Managed Metadata error - The data returned from the tagging UI was not formatted correctly
- Deploy SharePoint wsp solution package using PowerShell
- How to create classic site in SharePoint Online
- See actual SharePoint error exception modify web.config
- 'Edit Document' Requires a Windows Sharepoint Services-compatible application and Microsoft Internet Explorer 6.0 or higher
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- SharePoint installation error - Setup is unable to proceed due to the following error This product requires Microsoft .Net Framework 4.5
- How to add animated Gif to SharePoint Online Page
- [Solved] SharePoint Search Internal server error exception
- How to create SharePoint Document Library
- SharePoint - Use Today's Date Time in list view filter and calculated column
- How to redirect SharePoint Site Collection to different URL
- SharePoint error cannot connect to the configuration database
- [Solution] Java JDBC SQLException: No value specified for parameter 1 - Java
- Powershell Comments Examples - Powershell
- How to write hello world different languages syntax - HowTos
- How to Install Python Modules in VS Code - Python
- What does has notifications silenced in Messages App mean in iPhone - iOS
- How to know the version of Teams installed - Teams
- Get the Current Working Directory using Java Code - Java
- Get the Complete Sha256 Container ID for Docker Run Command - Docker