LEGACY CONTENT
This article refers to legacy products, components or features. Therefore, the content in this article is offered "as is" and will no longer be updated. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.

Introduction

When updating values (i.e. a data field) of a process instance without completing the process in pre-0807 releases of K2 blackpearl it was possible to use the [WorkListItem].[ProcessInstance].Update() method. In K2 blackpearl 0807 the [WorkListItem].[ProcessInstance].Update() method now requires a user with process Admin rights.

The recommended way to update values of a process instance without completing it is to use the Actions["UpdateWorkItem"].Execute() method. The Action must be configured to support the updating of the work item in order to use the Execute method in the API.

Configure the Action in K2 Designer for Visual Studio

The Add Action dialogue screen contains a radio button option that enables the Action to be updated without the Worklist item being completed:

This radio button must be selected in order to programatically update the value within a process instance.

Update the Work Item Using the K2 API

The recommended method uses an "update" action, as opposed to firing the ProcessInstance.Update() method, so will work without Admin permissions:

SourceCode.Workflow.Client.WorklistItem wi;
wi.ProcessInstance.DataFields["TestDF"].Value = "2";
wi.Actions["UpdateWorkItem"].Execute();

Remember that the Action must be configured using the This action will update the work item option during the design of the process, as demonstrated in the K2 Designer for Visual Studio section above.

The following sample will now only work if it is called by a user with Admin permissions on the process:

SourceCode.Workflow.Client.WorklistItem wi;
wi.ProcessInstance.DataFields["TestDF"].Value = "2";
wi.ProcessInstance.Update();