This issue comes up so often I thought it would be a good idea to highlight it in my blog.
This piece of code used to work fine previously.
oK2Connection.Open(serverName);
SourceCode.Workflow.Client.WorklistItem workItem = oK2Connection.OpenWorklistItem(serialNumber);
workItem.ProcessInstance.DataFields["WorkflowID"].Value = "test";
workItem.ProcessInstance.Update();
oK2Connection.Close();
However, there was a bug in the API which allowed all users to update the data even when they were not process admins. This was fixed in 0807 and had the side effect that you needed Admin process rights to execute the Update() method call.
Now the proper way to do the update is to execute an Update Action on the process. This is documented in detail in KB Article KB000307 (http://kb.k2workflow.com/articles/kb000307.aspx).
Basically this involved creating an additional action and configure it to use "This action will update the work item" instead of "This action will complete the work item". You then modify your code to execute the Update action instead. Note that this example isn't perfect as it hard codes the action name and there is no error handling. This is mainly for demonstration purposes. :)
oK2Connection.Open(serverName);
SourceCode.Workflow.Client.WorklistItem workItem = oK2Connection.OpenWorklistItem(serialNumber);
workItem.ProcessInstance.DataFields["WorkflowID"].Value = "test";
workItem.Actions[updateActionName].Execute();
oK2Connection.Close();
Posted
Wed, Jan 14 2009 10:27 AM
by
johnny