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?