Skip to main content

Is it possible to stop a process instance by writing code?
I am starting the process within the asp page by using the following code:


Connection conn = new Connection();


Conn.open(“blackpearl”);


 


ProcessInstance process1 = conn.createProcessInstance(“MyProcessesProcess1”);


Conn.startProcessInstance(process1);


Is there something similar to stop the instance?


Thx, Jochen

Hi Jochen,


 Yes indeed. Have a look at the following object in the SDK:


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


mngServer.Open();


mngServer.StopProcessInstance(procInstID);


Cheers,


 


 


I get the follwing error at the code statement "mngServer.Open();"


"Connection string has not been initialized. Connection to host server cannot be established."


Thanks


ok..I solved the error above.


This sode statment stops a process. So in the Management Console at process instances I see the instance with the status stopped.
Now I want to finish the process by using code. Is this possible?
So when I execute this code all open activities should be finished and the whole process is finished.


Thx, Jochen


Hi Jochen,

Yes there are several ways to do this: 

One idea is the following. You can design your process to always have a "END PROCESS" activity that does standard clean-up code. Then you use the above API (workflow management server) to call GoToActivity("END PROCESS"); to make the process go to this end activity. If I remember correctly, this will expire all other active activities (even if you have parrallel routes) and make the whole process go to that one activity, run that activity and that will then complete the process.

 


Reply