To end the child process abruptly from parent process


Badge +2

Hi,


Parent process triggers child process using IPC Event. After triggering parent process checks for a particular value in database. If false child process should be ended. How to implement this.


Thanks,


Shilpa


2 replies

Badge +9

Is it not possible for the child process to check for this value?  If not, well, I think the parent process will have to drop to code and use the API to get a reference to the child process.  The easiest way to do this would be if you could ensure a unique folio on the child process instance and search for it via management api.  Once you find it, you can take whatever action you need on it.

Badge +10

Hi Shilpa,


This is possible with SmartObjects. It requires a little thought about implementation, but in general it will work as follows:


In your parent process call the child process and then write a new record to a SmartObject containing the ProcInstID of the child process along with the ProcInstID of the parent. In the child process create a parallel activity from the start of the process and use an Asynchronous Server Event in this activity. In the event code, write the serial number of the event to the SmartObject record that was created by the Parent. The child process ProcInstID can be used to ensure the correct record is updated. Since an Asynchronous server event will wait for some system to finish it, the process will wait at this point while the other route of the child continues. The serial number in the SmartObject record can then be used by the parent later to finish the asynchronous server event.


To ensure the process completes after this server event is finished you will need to drop another Server Event into the same activity. This event will peform a "Goto Activity" and have the process go to a final state activity. The reason you need to perform a goto is so that all other activities in the child process can be expired and have the process go to one single activity. In this activity you can perform cleanup and set fields if required. When this event finishes, the child process will complete.


From the parent process you will have to interact with the child process using the SourceCode.Workflow.Client API from a Server Event. From this event you can query the SmartObject to get the child process serial number. Use this to open the server event item and finish it. In doing so the child will complete. Keep in mind that you will need to grant the K2 blackpearl Service account the "Server Event" process right on the child processes to be able to finish the event.


Please ensure that your parent will never try to connect to itself using SourceCode.Workflow.Client. This will cause locking issues on the K2 blackpearl Server. Since you are connecting to a different instance (child process) it should not cause a locking issue.


The above is a guideline and I hope it made sense. Reply to this thread if anything was unclear.


Regards,

Reply