Delete many process instances based on datafield.

  • 27 September 2010
  • 2 replies
  • 2 views

Badge +2

Hi Everyone.


 


I'm trying to delete many process instances based on their own datafield (projectId). Because these processes is started from an IPC event and I only stored the main (parent) process Id.


I would like to know how to delete all these child processes by looking at their "projectId" datafield (assigned from parent), or maybe even their folio name (it's the same as parent's folio)


 


Thank you.


 


2 replies

Badge +4
with blackpearl you can use the management api to delete process instances
what you have to do is to find process instances that have your process data field values - for this u can use smart objects

regards,
.jEy
Badge +2

Somehow I got it working by looking at process folio. Here's my code.


 


Connection conn = K2Connection.K2ConnectionOpen();


 


SourceCode.Workflow.Client.ProcessInstance procInst = conn.OpenProcessInstance(ProcessId);


 


SourceCode.Workflow.Management.WorkflowManagementServer server = new SourceCode.Workflow.Management.WorkflowManagementServer();


string connStr = K2Connection.SCConnectionString();


 


 server.CreateConnection();


server.Connection.Open(connStr);


 


SourceCode.Workflow.Management.ProcessInstances items = server.GetProcessInstances(procInst.Folio);


 


foreach (SourceCode.Workflow.Management.ProcessInstance item in items)


{


     server.DeleteProcessInstances(item.ID, false);


 }


server.Connection.Close();


conn.Close();


 

Reply