K2 Workflow: Creating sub-processes (aka IPC event)

Have you ever run into a scenario where you found yourself executing a certain number of activities over and over and wished you could have modularized it and wrote it as a separate function, similar to how most of the programming languages do. Well, there is hope in the K2 world and I will try to explain the steps on how to do it. To illustrate it better with an example (this is psuedo code only):

function SubProcess(a, b, c)




return x, y and z;


The above function SubProcess takes in the input parameters a, b and c. executes two functions DoSomething and DoSomethingAgain and then returns x, y and z.

How does one achieve this in K2? Using an IPC event.

As in any language, the first thing we need to do it create the function. In K2, this is very similar to creating another K2 process, so I won’t dwell too much into it since I am assuming you are already aware of how to create a process. Once the sub-process is created, deploy it to the server so that the main process can reference it.

Go to you main process, drag an IPC event from the toolbox and you will be provided with the option to specify the process name. Click on Browse and this will display a list of processes available. Select the sub-process from this list. Then specify what value to use as the folio number for this sub-process.

You then have the option whether this sub-process is to be executed synchronously or asynchronously. Choose based on your criteria. Then click on Next. You will then come to the “Process Send Field Mappings” wizard screen. This screen basically allows you to map any values that you pass into this sub-process. So in our example, it is a way to specify values for the input parameters for a, b and c. One cool thing that you can use is that if you name your input parameters the same as the parameter names you use in the main process, you can click on Auto-map and the mapping will be automatically done for you (else, you just have to drag and drop the mappings):

Click on Next to go to the “Process Return Field mappings”. This is how we map values from the sub-process to the main process, or in our example, a way to return x,y and z to the main process.

Click Finish and you are done and you can being using this sub-process as many times as you like!

All this is fine and dandy, but what are other benefits of using a sub-process (other than code reuse). To mention a couple:

  • It keeps the main process from becoming too long and makes it more manageable.
  • Even if the code is not being reused, it is helpful to break into separate modules so that it is better to investigate any issues.
  • And the best part, suppose you have to fix anything in the sub-process, you only need to deploy the sub-process and not the main process! So if any workflow was broken in the sub-process, you have to fix this only and the workflow activity will continue from there..

For more info, check out this link:


Hope you found this helpful!