Skip to main content
Nintex Community Menu Bar

How can I acces and update process instance data?

  • October 28, 2008
  • 2 replies
  • 8 views

Forum|alt.badge.img+1

Processes where running into error state because of custom process datafields containing wrong values. So I tried to access this data by API to change the contents of the fields. But everything I try does not work.


Example:


Connection

connection = new Connection();
connection.Open(_serverName, connectionString.ToString());


ProcessInstance

pi = connection.OpenProcessInstance(86);


this code ends in an error like 'no such processinstance for user ...'. So this means I have to impersonate before but that didn't help. I guess because the process instance is not assigned to a user while being in error status. Also when I try to open a worklist but the process instances in error state don't appear in worklists.


So I tried this:


ServerItem

serverItem = connection.OpenServerItem("71_86");


That tells me that there is no item for this serial. I guess the serial is  'processID_processInstanceID' - is that wrong? What exactly is a ServerItem? Is it everything or only items that are not assigned to a user?


I also tried to use


SourceCode.Workflow.Management.

WorkflowManagementServer


and can list all process instances but there are no methods to work with the datafields. 


Help would be nice!

2 replies

Forum|alt.badge.img+6
  • October 28, 2008

Hi,

First of all, you need to have 'Admin' rights on the process to call the following method: OpenProcessInstance.

Then, the following code sample must work in your case :

SourceCode.Workflow.Client.Connection connection = new
SourceCode.Workflow.Client.Connection();

SourceCode.Workflow.Client.ProcessInstance processInstance;

connection.Open("<STR_YOUR_SERVER>");
processInstance = connection.OpenProcessInstance(<INT_PROCID>);

processInstance.DataFields["<STR_YOUR_FIELD>"].Value = <STR_YOUR_VALUE>;

processInstance.Update();
connection.Close();

I hope that helps.

Regards.


Forum|alt.badge.img+1
  • Author
  • October 29, 2008

Thanks!


The missing userrights were the problem.