Skip to main content

Hi,

How can I access and update the datafields of a process instance when I only know the process instance id? In this particular case, I'm running as a user who has Admin rights and the worklist item isn't in their list.

I have tried opening a SourceCode.Workflow.Management.WorklistItem but this does not provide access to the datafields.

It have tried using SourceCode.Workflow.Management.WorkflowManagementServer.GetProcessInstances() but it doesn't appear I can update the datafields from there either.

I cannot open a normal connection impersonating a specific user because the destination is a role, not a user.

Hi,


Why do you want to update a field from somewhere else a workitem? What is your business need behind?


Nevermind, If you have K2 admin rights. Then you can use Workflow.Client API.


Your code must be something like :


ProcessInstance PI = k2ClientConnectionObject.OpenProcessInstance(<yourID>);


PI.Datafields["<yourdatafield>"].Value = "<yourvalue>";


PI.Update();


If you are only talking about accessing information, an alternative method is to use the workflow reporting smartobject automaticaly created with the process.


HTH


Thanks Jan, that worked! I didn't realise that a user with admin rights can open a process instance under with normal connection.

Here is the situation: I have a bunch of workflows for employees. When an employee leaves the company, all these workflows need to be canceled. I have a service running with K2 admin rights which opens the global worklist item and makes it go to a particular activity. However, I need to update a specific datafield before I do this.


Excellent, glad you be sorted out.


For your business need, these solution is the best approach. :-)


Reply