Geeks With Blogs
Molnar Tibor blog

Context
In a production environment we started to receive, apparently randomly this error message. We have a complex workflow using InfoPath forms developed in Visual Studio, we applied multiple patches by regac-ing new versions of the workflow assemblies, retaining of course the fully qualified names of the assemblies. Also we use a test environment, where regression testing was done by dedicated test engineers.

Shooting in the dark
We found this blog http://geek.hubkey.com/2007/09/locked-workflow.html, which suggested to set the task item workflow version attribbute to 1 (task[SPBuiltInFieldId.WorkflowVersion] = 1;). It solved only temporary the problem, the following access to the task locked again the workflow.
Digging into the sharepoint assemblies, I found out that in Microsoft.SharePoint.dll assembly in the Microsoft.SharePoint.Workflow.SPWinOEItemReceiver class in the ItemUpdating is created the exception causing the "This task is currently locked by a running workflow and cannot be edited" message:

properties.ErrorMessage = SPResource.GetString("WorkflowTaskLocked", new object[0]);

The exception was thrown if the "WorkflowVersion" property of the task created by the workflow was not equal with the value of the PBuiltInFieldId._UIVersion property. In the same method we have:

properties.AfterProperties["WorkflowVersion"] = (int) itemById[SPBuiltInFieldId._UIVersion];

This doesn't make too much sense, the workflow version is set to the the ui version of the task item. The UI version is equal with (512 * major version + minor) version and beacuse in the task list we don't have minor versions, then the ui version is 512 * the version number. I created an ItemUpdating event handler on the task list.

For the from workflows not having this problem (receiving the error message above) the event handler was called two times, first time from the due to the postback from the client browser and second time by the workflow persistence job having elevated privileges. For the workflows having the problem, the second call was not done immediatelly, it was done only on any following user postback by submitting or saving an Info Path form attached to any workflow instance. More than that, we had in the workflow an OnTaskChanged Sharepoint Workflow activity, for which the 'invoked' event was not fired. It was very confusing.

The lucky guess
After hours of digging I restored the workflow assemblies to an older version. Suddenly, some workflows started to run!

In the Wofklows table in the Sharepoint content database, each workflow has a corresponding row, and one of the columns contains the serialisation of that workflow, I think it's a binary serialisation and the rule of thumb is that we deployed patches were the new version of the workflow classes didn't have anymore a 100% binary serialisation match with the already running workflows. We didn't had these problems in the test environments because all the worklows were newly created.

Conclusions

  • the message "This task is currently locked by a running workflow and cannot be edited" didn't suggested at all what was the root cause of the problem, it was totally confusing
  • don't apply patches to the workflow assemblies only if you are sure that the binary serialisation will be 100% compatible with the prevoius versions from the workflow assemblies (no attributes are added or removed from classes etc.)
  • leave in the test environment workflows running from previous versions of patches to catch this kind of exceptions
  • if is possible, version you workflows
Posted on Saturday, March 1, 2008 2:07 AM SharePoint 2007 | Back to top


Comments on this post: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
I have a complex workflow that uses InfoPath forms. I use versioning (change both AssemblyInfo.cs and workflow.xml) when I make changes and always create a new association after deploying the new code. I also reset both SPTimerV3 and IIS, just for good measure.

Versioning doesn't prevent the workflows from becoming "stuck" (DelayActivities don't "pop" when the value of column DeliveryDate in their row in table ScheduledWorkItems in the content database says they should) if I try to run five instances concurrently. Have you ever seen this behavior? I have an open case with Microsoft since June 2, 2008, but have not received an answer other than "a fix is imminent" (no specific date).
Left by Fred Morrison on Jul 07, 2008 2:05 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Hi,
we opened too an issue with the Delay activity at Microsoft since month, it behaves unpredictable in workflows hosted in MOSS. The support engineer pointed out a bolog entry on the Sharepoint Team blog which gathered feedback from the community in order to reproduce it.

Please check my blog entry http://geekswithblogs.net/MTex/archive/2007/10/02/115766.aspx , we made a workaround for our specific scenario. Maybe u have something similar. Let me know if this helped.

Cheers,

Tibi
Left by Tibor Molnar on Jul 07, 2008 2:35 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
We had problems with the Delay activity until we installed the hotfix from KB932394. We also had problems on our test farm with clocks not being synchronized causing Delay activities to wake up later than expected.
Left by Anonymous Coward on Jul 10, 2008 11:45 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Hi,
i have realised that
if (Convert.ToString(task[SPBuiltInFieldId.TaskStatus]) == "Not Started") && Convert.ToString(task[SPBuiltInFieldId.WorkflowVersion]) != "1")
then this error occurs.
I think this is the way of SharePoint to put a lock on a task item.
Left by aytekin on Oct 14, 2008 5:03 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...

Cool Stuff

All the steps are clearly mentioned.

Thanks
Left by taskworkflow on Dec 24, 2008 7:54 PM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Hi Tibi,

I've been trying to solve this problem for 2 days now but still unsucessful. Could you please tell me how to "restore" the workflow assembly? I appreciate your response.

- Linda
Left by Linda on Feb 13, 2009 8:40 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Hi,

I am having that error too but the problem is that my workflows are from SPD and I do not know how to change their version I got one workflow that in one step goes paralele to 2 users at same time one can complet task the other get this error "This task is currently locked by a running workflow and cannot be edited" this workflow was made in sharepoint desingner.

thanks in advance

Cordovil
Left by Manuel Cordovil on Jul 13, 2009 9:36 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
We have the same issue as Cordovil, we have a step in our workflow that runs the task in Parallel.

First we have one workflow that assigns tasks to as many people as the workflow initiator requests.

Then a second workflow is started when any new task is created. This second workflow has tasks that run in parallel pausing until the due date or waiting for the status to = complete. When the user does submit feedback, the workflow does not mark the task complete but does update the task status field as complete. Also, some of the users who are assigned the task are listed as "Not Started" and when these individuals try to submit feedback they get the "This task is currently locked..." error message.
Left by Shannon on Sep 04, 2009 12:47 PM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Hi,
Even I am facing the same issue as Cordovil. Approval Parallel workflow from SPD is used. Out of mulitple users to whom the tasks are assigned in the workflow only one user is getting the error message "This task is currently locked by a running workflow and cannot be edited".
Thanks in advance.
Vasudha
Left by Vasudha on Oct 01, 2009 2:14 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
I too am having the same problem using 2 "Collect Data From User" in my SPD workflow. And I am getting the "This task is currently locked by a running workflow and cannot be edited" message as well.

Did anyone find a solution? I would appreciate any feedback.

Mark
Left by Mark A. Rupert on Jan 20, 2010 8:10 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Hi,
I am too having this issue with "This task is currently locked by a running workflow and cannot be edited". My WF is utilising parallel activity in which four tasks are being assigned to four different users. We are using custom forms that are utilizing AlterTask method to submit the changes user is making to the task.
Did anyone found the solution to this problem? I am not changing the version of workflow - the DLL is simply installed in GAC and it sometimes behave in unusual way.
Thanks in advance
Left by Dmitry Y. A. on Mar 02, 2010 3:29 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Hi, I´m with this same problem too. But a thing that I noticed is that I changed my Collect command and create a new one, but when I upload my wf, it didn´t update on approval list.
I create differents names for each collect, but it appears always the first one.
somebody actually resolved this?
Left by Will on Mar 16, 2010 4:34 PM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
If i have to make a minor change in the workflow code i.e. the "from address used in all emails". then will it make the serialization mismatched?
Left by DanishAli on Mar 26, 2010 7:57 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
WoW, toally wasted 2 days making a workflow that can't flow. How freaking annoying.
Left by J on Jul 03, 2010 10:53 PM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
This post (not mine, I swear) sounds like it has a good explanation of the problem observed here: http://blogs.code-counsel.net/Wouter/Lists/Posts/Post.aspx?List=c04a88a9-d138-4ac3-a2bb-b95c9fdd114e&ID=118

Not the same problem I'm having :( , but hopefully someone will find it useful...
Left by Dave on Sep 15, 2010 12:38 PM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
How can we prevent deadlock i workflows tasks in Moss
Left by guru on Oct 08, 2010 3:22 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
No proper answer received yet. I deleted all workflows and again installed it. on the first task creation itself the error occurs. So
Left by Abhishek on Oct 12, 2010 1:33 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
i found a solution for myself.
1. i found that wf creates eventreceiver with sequencenumber 10000 for each task in workflow. So you too need your own receiver
2. after first change ontaskupdate set task lock on task item till you'll invoke taskcomplete activity and this lock is workflowversion=uiversion * 512(workflowversion=1 nolock but not so simple :)
3. I needed in my workflow to go to the next state if some field approvalstatus has changed. So i create receiver itemupdating and in it do the following:
if (properties.AfterProperties["ApprovalStatus"] != null)
properties.AfterProperties["WorkflowVersion"] = 512;
else
properties.AfterProperties["WorkflowVersion"] = 1;
And it works. Good Luck guys.
Left by Grigoryev Pavel on Oct 24, 2010 4:47 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
I am suffering from the same problem. Please help.
Left by signs and symptoms of cancer on Jan 03, 2011 7:33 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Been searching for an hour on Google to find the solution for this error. Thanks to everyone that's commented so far - I'll have a read through and so how far I can get with it!
Left by Mobile Broadband Dongle Reviews on Feb 07, 2011 7:19 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
Nothing worked for me, until I found this: http://blogs.sharepointpro.net/2011/02/24/this-task-is-currently-locked-by-a-running-workflow-and-cannot-be-edited.aspx?results=1

Unlock all locked workflow tasks with a single PowerShell command, ridiculously easy.
Left by Ryan on Dec 21, 2011 11:16 PM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
I have the same problem.
How did you make with your Powershell command? Can you send it to me please?
Left by Sophie on Feb 10, 2012 4:22 AM

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck?
Requesting Gravatar...
looks too geeky
Left by vicky on Aug 31, 2012 5:10 AM

Your comment:
 (will show your gravatar)


Copyright © Molnar Tibor | Powered by: GeeksWithBlogs.net