Updating Locked Workflow Task

When trying to update a workflow task item in code, you may get the error “This task is currently locked by a running workflow and cannot be edited.”

This error gets thrown because the ows_WorkflowVersion of the task list item has been set to 512.

There may be a good reason it’s set to locked (i.e. currently being updated) but it you really really want to still update the task, you can override the flag.

task[SPBuiltInFieldId.Title] = "Just update me";
task[SPBuiltInFieldId.WorkflowVersion] = 1;
task.SystemUpdate(false);

Been working fine so far for me, but there may be unforeseen consequences of ignoring the locked flag…

May also be useful to unlock a locked workflow task due to errors.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s