Sharing the experience search

Search sharing-the-experience.blogspot.com

Monday, March 8, 2010

Understanding and resolving the workflow task locking issue

A not so uncommon error that people encounter with SharePoint workflow is running into locked tasks. You know, the error that you get when working with workflow tasks, usually on your developer machine. You might get the error message "This task is currently locked by a running workflow and cannot be edited."

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

Extremlly useful article to understand the lock task problem created by workflow.
In essence, be sure that you have healthy running an event handler attached to the item which also has a workflow.

And here is the result which causes the "locking" and hummer-way to fix it:
Locked Workflow

My investigation concluded that the task with locking issue "The file is currently checked out or locked for editing by another user"  can be identified by looking at the task property Level . If the item is locked - the value is
"Checkout"
 
Here is a powerful script  in PowerShell to free the tasks up that had been locked:

$tasklist=$web.Lists["Tasks"]
Foreach ($task in $tasklist.Items) 
  {If($task.Level -eq "Checkout") 
    {
      Write-Host $task.Id
      $tasklist.RootFolder.Files[$task.Url].UndoCheckOut() 
    }
  } 

No comments:

Post a Comment