Domanda

I have a SharePoint 2010 workflow that creates a task. The task has custom form and custom code executed when the form is submitted.

Inside the code I'm trying to set the Completed Status on the task when some conditions are met:

.....
SPListItem taskItem = this.workflowProperties.TaskList.GetItemById(...);
taskItem["Status"] = "Completed";
taskItem.Update();
......

I get this error:

This task is currently locked by a running workflow and cannot be edited

There are a lot of hits on this when you do a search and lots of fixes (workarounds?!).

My question is, what's the correct (or by the book) solution for fixing this?

È stato utile?

Soluzione 2

I eventually went for adding a UpdateTask activity in my workflow to update the properties I was interested in. It didn't involve any workaround code and I never got the "This task is currently locked by a running workflow and cannot be edited" since then.

Altri suggerimenti

This explains it in a clear way, along with the solution : http://blogs.code-counsel.net/Wouter/Lists/Posts/Post.aspx?ID=118

There can be many causes for this error, but one of them can be when you have too many tasks in parallel in a single workflow (In my case that is what was happening). This often means that multiple processes are attempting to access a workflow task at the same time. A large workflow has more tasks and more updates in the single workflow, so more chance of causing a lock. Also if a lock does occur, a larger workflow can make it difficult to determine the point at which the lock happened while a smaller workflow will always be easier to diagnose.

But under normal circumstance. it takes time and later it can be processed! successfully!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top