SharePoint Pals
 | Sign In
How To Identify Complexity of SharePoint 2013 or 2010 Workflow to fix errors while compilation
by Senthil Kumaresan 20 Jan 2014
SharePoint Architect
Today  :   21     Total  :    14952

SharePoint Declarative Workflows have certain limitations that are not well known to many people . Try this Poweshell script to identify the complexity of a SharePoint 2013 or SharePoint 2010 declarative workflow to fix the compilation error due to complexity of WorkFlow.

Too complex workflow does not compile and hence cannot be deployed. The complexity limit for a workflow is defined in SharePoint using a Web Application level numeric property called UserDefinedWorkflowMaximumComplexity and the Default value of the property is 7000 which is the maximum allowed limit for a single workflow to successfully run. This can be adjusted by the farm administrator by updating the property with PowerShell. And there is a ceiling limit of a workflow size which is 10000 restricted by the .Net Workflow Foundation compiler. If you develop a too complex workflow and try to compile it in SharePoint Designer then you might get the below error if your workflow exceeds the complexity limit

“Errors were found when compiling the workflow. The workflow files were saved but cannot be run. Unexpected error on server associating the workflow”

To know more about this, please check out the KB article 2557533

To fix the error you will have to redesign and break them into multiple workflows to achieve the business functionality.

How can I find the complexity of my workflow?

The complexity is based on the No. of Start Nodes plus the No. of ActivityBind Attributes found in the .XOML file of the workflow.

I have developed a Simple powershell script below which would count the no. of start nodes and the no. of ActivityBind Attributes from the .XOML file of the workflow.

Save the below script as Powershell file

     [string]$xomlfile = ""
 $reader = [system.Xml.XmlReader]::Create($xomlfile)
 	[int]$nodecount = 0
 	if ($reader.MoveToContent() -eq "Element")
 		if ($reader.MoveToAttribute("x:Name"))
 			$wfclassname = $reader.Value
 	[System.Xml.XmlReader] $activityreader = $reader.ReadSubtree()
 	while ($activityreader.Read())
 		if ($activityreader.NodeType -eq "Element" -and $activityreader.IsStartElement())
 			for ($i = 0; $i -lt$activityreader.AttributeCount; $i++)
 				if ($activityreader.NodeType -eq "Attribute" -and $activityreader.Value.ToUpperInvariant().Contains("ACTIVITYBIND"))

Run the Above Script by providing the .XOML file of your workflow for the xomlfile parameter


.\GetSingleWFComplexity.ps1 –xomlfile c:\docsworkflow.xoml

The output would be numeric value which is the actual complexity of the workflow that you have developed.

If you had exceeded the pre-defined limits set by the farm administrator then you might try breaking the logic of the workflow into multiple workflows.

blog comments powered by Disqus

SharePoint Pals

SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile


Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community

SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to in a word document.

Related Resources

Recent Tweets

Twitter October 23, 22:21
How to Add/Remove User Custom Actions (in Site Actions Menu) Programmatically using CSOM PNP in SharePoint -

Twitter October 21, 21:34
How to Add a JS Link Reference to the Display Form or Any other ASPX Programmatically using CSOM PNP in SharePoint -

Twitter October 20, 13:01
How to Add a JS Link Reference to the NewForm and EditForm Programmatically using CSOM PNP in SharePoint Office 365-

Twitter October 12, 12:15
How to Deploy Provider Hosted Apps (Add-Ins) by App Stapling in SharePoint Office 365 -

Twitter October 11, 13:39
How to Deploy Provider HostedApp programmatically using CSOM in SharePoint Office 365 Activating Developer Feature -

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation