Skip to main content

Dear all,


Our K2 have a lot of old process instances that do not need to use, because:


- they are error


- or they are not complete and they are too old (more than 5 months)


- or they are complete but the CC event does not complete


I want to:


- list them all


- remove process instance of case 1 and case 2


- expire CC event of case 3


 


I can list case 1.


1/ In case 2, I listed by using _WorklistSlot with status = 0. Is it correct? Because _WorklistSlot has 4 status: 0, 1, 3, 4


2/ I don't know how to list case 3.


3/ I don't know how to remove a lot of instances by script.


Please help me.


 


Thanks very much


imagic

Hi imagic,


For this requirement you will make use of the SourceCode.Workflow.Management API.


You will need to build up criteria to filter the processes and then call the WorkflowManagementServer.GetProcessInstancesAll() method to return the processes. This method makes use of the SourceCode.Workflow.Management.Criteria.ProcessCriteriaFilter object and you can add a SourceCode.Workflow.Management.Criteria.RegularFilter to the ProcessCriteriaFilter object to filter your processes.


For case 1 and 2 you can check the status of the process and filter on that. (Use some of the other methods of WorkflowManagementServer to see what the column name is and the possible values). With the returned collection call the WorkflowManagementServer.DeleteProcessInstances() method for each process instance to delete the instance. The deleteLogEntries flag will allow you to keep/delete reporting data for this instance.


For case 3 you can probably filter on activity name. When you have these processes you can call the WorkflowManagementServer.GotoActivity() method to have the process go to another activity. Alternatively you can delete the process instance, preserving the reporting data.


I hope this helps!


Regards,


Thanks JohanL very much.


I'm trying to use SourceCode.Workflow.Management API. Up to now, I can't connect, it alert in line 2: "not connected"


WorkflowManagementServer wm = new WorkflowManagementServer(_host, _port, _username, _pass, _securityLableName, true);
wm.GetProcessInstancesAll("CC", "", "");


 


Thanks


imagic


Umn, I can connect now. Thanks for your help :)


Dear all,


I have a last question: status column of  _ProcessInstance ?


I know that: when Process instance has status = 2, it is active. But I don't know how about 0 and 1 ?


Thanks very much


imagic


Hi imagic,


0 = Error


1 = Running


However you can query the _Status table in the K2ServerLog database to get all the status names. The ones for GroupName = Process will have the above.


Regards,


In K2 blackpearl you already have ProcessInstance SO, try.


Reply