Continue an existing process instance from another process instance

  • 6 January 2010
  • 3 replies
  • 1 view

Badge +5

Hello,


I am stuck on a current problem where I am trying to continue one process from another.  Here is the situation I have Process A  that has a Smart Object connected with a simple SmartBox table that stores a ProcessID_ActivityDestinationID.  The next activity has ServerCode event with only one line which is K2.Synchronous = false;  In Process B I query the SmartObject and retrieve the ProcessID_ActivityDestinationID from Process A. 


I would then like to continue Process A using the ProcessID_ActiityDestinationID from Process B but I'm unsure how to do this.  Is there away to find the continue Process A from Process B?


From outside of K2 using the API it seems that you can use code such as the following to continue the item


SourceCode.Workflow.Client.ServerItem item = k2Connection.OpenServerItem(SN);  where SN is the ProcessID_ActivityDestinationID but this will not work from within a Code event within k2.


Does anyone have any suggestions?


3 replies

Badge +9

It is normally not a good idea to call the SourceCode.Workflow.Client APIs from the server itself as in most cases you could potentially lock up the server threads.  Certain cases like setting Out of Office status is alright.


I would suggest using an external queue mechanism with an external program to do that call.


The only other possible way I guess would be to try using IPCs (which may or may not be possible depending on your application design).

Badge +5

I haven't tried this, but maybe you could put a default client event in Process A with one action where you want the process to hold and use a service account (i.e. ISS Application Pool account)  as the destination user.  In Process B, you could make a web service call (or something similar where the K2 service is not executing the code), which opens the web service's service account's worklist and then executes the worklist item.  You would probably need to pass in enough information from Process A to Process B so Process B would know which worklist item to complete such as Process Instance ID, Activity Name, etc.

Badge +5

I ended up calling it from an external program (Sharepoint) and everything is now working.  Thanks for the help.

Reply