GD Bloggers

This is the blog site for Microsoft Global Delivery Communities focused in sharing the technical knowledge about devices, apps and cloud.
Follow Us On Twitter! Subscribe To Our Blog! Contact Us

SharePoint Workflow Error: This task is currently locked by a running workflow and cannot be edited

SharePoint Workflow Error: This task is currently locked by a running workflow and cannot be edited

  • Comments 6
  • Likes

Many times you were developing a Visual Studio workflow for SharePoint. You simply create a task using the "CreateTask" activity. After a while, you need to update the task and you do not have a valid correlation token to use the "UpdateTask" activity, for example, because you are creating a task inside a replicator (I will blog about this later). for example, inside your workflow you write...

SPListItem item = workflowProperties.TaskList.Items.GetItemById(id)
item["Status"] = "Completed";
item.SystemUpdate();

The last line will give you error "This task is currently locked by a running workflow and cannot be edited", a possible work around for this issue, is to ensure that the workflow version number of the task is 1 before you update. Your code should look like the following...

SPListItem item = workflowProperties.TaskList.Items.GetItemById(id)
item["Status"] = "Completed";
item[SPBuiltInFieldId.WorkflowVersion] = 1;
item.SystemUpdate();

Happy Coding:)

Comments
  • nice post ahmed. Thanks a lot.. it works very well..

    keep up the good work.

  • Thanks! This saved me a lot of time.

  • I hope this saves my head! :D

  • Warning: this workaround causes OnTaskChanged activities NOT to be triggered...

  • I don't think you realize how useful this was!!! Thank you!

  • I still had to muck with Extended Properties to get my task 'unstuck', but this saved my bacon. Thanks.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment