⛔️ 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!
- SharePoint error - An exception occurred when trying to issue security token: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms..
- PowerShell iterate and get all SharePoint sites and sub sites
- SharePoint Online: Editing session has ended Message
- How to Share Microsoft SharePoint Site with Users or Groups
- How to delete SharePoint Online List Item using REST API
- SharePoint List excel import - This table exceeds the maximum number of supported rows
- How to disable SharePoint subsite creation option for owners
- SharePoint 2010 August 2015 Update KB3055049 - Duplicate Document ID issue bug fixed
- SharePoint Server 2016 Preview installation error - This Product Key isn't a valid Microsoft Office 2016 Product Key. Check that you've entered it correctly.
- How to upload file programmatically to SharePoint Document Library using Server Object Model C# .Net
- Access URL for SharePoint Tenant Admin Center (Online Office 365)
- Error when deleting SharePoint Online folder or file
- How to extend retiring SharePoint 2010 Workflows and continue with Office 365
- How to generate client id and secret to register SharePoint App with OAuth
- How to delete SharePoint List Item programmatically using C#.Net
- How to retrieve all SharePoint Online List Items using Rest API
- [Solved] SharePoint Search Internal server error exception
- Create SharePoint Site Collection using PowerShell New-SPSite
- Fix SharePoint PowerShell error - The term Get-SPweb is not recognized as the name of a cmdlet function script file or operable program
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- SharePoint Server 2016 installation System Hardware requirements
- How to create SharePoint Online List Item using REST API
- Changed AD user display name showing old name in SharePoint
- Recommended size and resolution for SharePoint Online Site logo
- Microsoft 365: How to Turn Off Delve in SharePoint Online for All Users
- WARNING: Python 2.7 is not recommended [macOS Big Sur] - MacOS
- How to know installed version of Homebrew - MacOS
- Python: Print Dictionary Line by Line Example - Python
- Java equals method - Tutorial - Java
- How to verify if java is installed on the computer and get version detail - Java
- How to List All Users in Linux - Linux
- You're not on Teams yet, but you can set it up for your organization. [Microsoft Teams Login Error] - Microsoft
- Fix Microsoft Windows Update Error 80072EFE - Microsoft