SP2010 Workflow Template Validation Rules and limitations of the Visio-driven workflow model

I have been looking into the new SP 2010 Workflow Template that comes with Visio 2010 Premium with the intention of building complex workflows entirely within Visio and then exporting to SP Designer for implementation.

Sound easy? Well everything works fine if you plan to use the default shapes provided by Visio (and map to SP Designer default actions/conditions). Using these you can build workflows as complicated or simple as you like and have full synchronization to and from SP Designer.

The problem with this method is that you are limited to the default actions and conditions that ship with the product. Now granted this default set is better than 2007’s offering but there will certainly be lots of cases where the default set simply does not do the required job and a custom action or condition is required.

Custom actions and conditions can used easily within SP Designer and work really if your building your workflow there but if your planning to import and use those custom actions in your Visio model then you might want to re-think your strategy. Visio will allow you import these custom actions and they are shown with their own shape but you are unable to reuse these custom shapes in other parts of your diagram.

How does it Visio block you from doing this?

Well if you look at the validation rule set for the SP Workflow template using the bVisual Validation Explorer from  David Parker– the SharePoint template has the following rules

ID Name Description
1 MultipleStartWorkflows The diagram must only have one workflow and one start shape
2 NoStartShape The workflow must have a start shape.
3 InvShapeType The shape is not a SharePoint workflow shape. Only SharePoint workflow shapes can be connected in a workflow.
4 ConnectonToParent Loop back to parent shape is not allowed.
S OrphanConnector The connector must be connected to two workflow shape.
6 TerminateHasChildren The terminate shape must not have outgoing connection.
7 NoIfElseBranches The condition shape must have at least one outgoing connection with label Yes or No.
8 NofElseValue The condition shape does not have connectors labelled with Yes or No.
9 StartHasParent The start shape must not have incoming connections.
10 SequentialParallel Parallel activities that are also sequential are not allowed.
11 DuplicateConnections Duplicate connections exist between workflow shapes.
12 NestingDepth Workflow nesting levels must not exceed a maximum of 10
13 CompoundCondition A compound condition cannot be manually added to a workflow diagram. The compound condition can only be generated when importing workflow from SharePoint Designer.
14 CustomAction A custom action cannot be added to a workflow diagram. The custom action can only be generated when importing workflow from SharePoint Designer.
15 UnconnectedWorkflowShape The workflow shape is not connected to the workflow.
16 NoTerminateShape The workflow shape is not connected to a terminate shape
17 InvalidConnector The connector is not a SharePoint workflow connector. Use AutoConnect or the connector tool to connect your shapes.
18 CustomCondition A custom condition cannot be added to a workflow diagram. The custom condition can only be generated when importing workflow from SharePoint Designer.

The rule that we encounter when trying to reuse custom actions in your Visio model is Rule #14 ‘Custom action cannot be added to workflow diagram..’ (see table above).

So the rule set is preventing the reuse of custom actions/conditions for some unspecified reason. I’m sure there is a valid reason for blocking this (maybe the Visio team simply ran out of time?) but the rules are customisable, so you should just be able to edit or override the rule and be done with it, right?

Well no actually. As it happens there are two methods of performing diagram validation using Visio 2010 – deploying the rule sets into the Visio template or writing a Visio solution and burying the logic within the code to fire on the RuleSetValidated event (more info on the Visio Team Blog). Unfortunately for those of us wanting to customise the SharePoint validation rules the SP Workflow template uses the latter method and we are unable to view / modify the logic.

So if you are planning to develop complex and powerful workflows for SharePoint 2010 then you might want to rethink your approach and decide whether you will need to use custom actions / conditions or whether the default set will suit your purpose.

Having said this, it is still possible (and very useful) to use custom actions / conditions and build your workflow entirely within SP Designer then export out to Visio for workflow visualisation. This way you will have accurate workflow representation including all custom actions / conditions but you will not be able to make changes within Visio – it must be done at the SP Designer level.

I intend to look further into this matter to see if there is some way in which custom actions / conditions can be reused  and Visio be leveraged for complex workflow design so look out for updates in this space shortly.

Update 1: Nothing so far from TechNet forums but I’m  awaiting a response from Microsoft to see if there is anyway around this issue.