Workflow Error: System.InvalidOperationException and the Correlation Token

I got a slightly obscure error message when trying to run a DeleteTask activity in my workflow:

System.InvalidOperationException: Correlation value specified does not match the already initialized correlation value on declaration taskToken for activity deleteTask1.

Hmm. I checked the correlation token though – and it was fine. And what’s it doing initialising another token? Found the answer though, courtesy of Matt Morse – I’d not set the task ID property for the delete task activity.

This did lead me around to wondering why I have to? I mean, we’ve a correlation token for the task. The correlation token contains the TaskID. And yet I have to specify both of these things to the DeleteTask activity to identify the task I want deleted? Something ain’t right there…

Workflow Error: System.InvalidOperationException and the Correlation Token

Why is Audit in SharePoint Workflows so hard?

Previously I’d pointed out an article about a problem with SharePoint workflows where the data gets ‘disconnected’ from the user interface after a number of days. Robert Bogue wrote a nice summary of it, explaining why it behaves this way and how to get around it. Anyway, I was catching up on my RSS feeds, and I came across a follow up post that I just had to respond to.

Read his post first; this is just my thoughts. Done? Good.

Robert Bogue makes some good points. I totally agree with him on the second point – Workflow History isn’t an Audit. However, this does sort of highlight the crux of the issue – that there is no Audit. One is mentioned in his previous post, but I’ve never managed to figure out what he meant by that, or to find a decent audit in Workflow that I didn’t have to build myself. And I just keep thinking that this is something that a plug-in tracking service ought to be able to provide…

I guess my ‘What were they thinking!’ isn’t that there is the auto-cleanup, but rather why didn’t Microsoft offer an audit mechanism out of the box. I asked Lawrence Liu about that once at a SUGUK meeting – he said that SharePoint Workflow “wasn’t intended to be an enterprise solution”. Fair enough, if that’s what they want to do (and to leave space for the likes of K2 and Skelta), but then stop advertising SharePoint as having user configurable workflows.

A number of our customers have gone through the logic of:

  1. SharePoint is an Enterprise level system
  2. It has workflow built into it
  3. Therefore we can use workflow to support our enterprise’s processes

They’re pretty disappointed to discover that it lacks pretty basic things like audit. I can’t say I blame them either. But I digress.

Regarding his first point about configuring the timeout – writing an application isn’t a good general option. I’ve no doubt it works, but SharePoint administrators are necessarily programmers. Even if they are, there’s no guarantee that they’re good SharePoint programmers. The setting in the manifest – that I like. Don’t depend on your users being able to code their own solutions. Further, I don’t know how this would apply to SharePoint Designer workflows, though personally I steer clear of them.

So yes, I’d agree with Robert – it’s not a ‘Huge Issue’, but it is a problem.

Why is Audit in SharePoint Workflows so hard?

Auto-Cleanup of Workflows in MOSS

I just read an interesting blog post about how MOSS Workflows lose their association with their history after 60 days.

I guess it sort of agrees with my conclusion of MOSS workflow – that the auditing is awful. I mean, I get that ‘Workflow History’ items fits nicely with the SharePoint ‘item’ idea, but couldn’t we have a table for this? Or at least an implementation of Workflow Foundation that lets us plug-in our own tracking providers?

If I could get a week free, I’d write one and stick it on codeplex (for the glory).

Auto-Cleanup of Workflows in MOSS

SharePoint Workflow and when to use it…

When building SharePoint workflow solutions you need to be very careful in only using it for small, single document-centric processes, and you need to try to avoid the ‘pain points’. For processes that push the boundaries of what workflow can do, you should consider redesign of the solution to reduce the workflow element or alternative products.

In a collaboration and publishing system like SharePoint, some sort of support for standard business process is essential. SharePoint workflow supports that for simple processes, but it is not enterprise grade workflow (yet). Indeed, out of the box it doesn’t work (at least, not fully). I’ll explain some of the issues with SharePoint Workflow later, but first I want to describe what SharePoint workflow is. Continue reading “SharePoint Workflow and when to use it…”

SharePoint Workflow and when to use it…

Error: The event receiver context for Workflow is invalid

This is an obscure error:

Error in commiting pending workflow batch items: System.InvalidOperationException: The event receiver context for Workflow is invalid.
at Microsoft.SharePoint.SPEventReceiverDefinition.ValidContext()
at Microsoft.SharePoint.SPEventReceiverDefinition.ValidReceiverFields()
at Microsoft.SharePoint.SPEventReceiverDefinition.

GetSqlCommandToAddEventReceivers(IList`1 erds)
at Microsoft.SharePoint.Workflow.SPWinOESubscriptionService.

CommitNewSubscriptions(Transaction txn, IList`1 erds)
at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.

ProcessWorkItemBatch(Transaction transaction, Work method, IList`1 workItemBatch)
at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.

Commit(Transaction transaction, ICollection items)

Let’s skip over wondering what an erd is (event receiver definition maybe?)- the solution to this is simple, but not obvious. Check you have created properties for TaskID, TaskProperties and Correlation Token. I found this solution at Robert Bogue’s blog. As a side note it is a REAL pain in the ass that setting up TaskIDs and TaskProperties is so manual – or at the very least that tasks with unassigned values for these do not appear with the red ‘warning’ exclamation mark in Visual Studio.

Error: The event receiver context for Workflow is invalid

Get around workflow version issues – and better ways to start workflows

Workflow versioning in SharePoint by Daniel Herzog. Yeah, it’s a problem that I’ve been wondering about, and his suggestions are valid. I was interested by the link to Start workflows from the context menu – to me, this is a much more natural place to start a workflow from.

Found from Julie’s Blog

Get around workflow version issues – and better ways to start workflows