Parent-Child Workflows in K2 Studio (Basic)
This tutorial provides the step-by-step instructions for configuring a simple parent-child workflow using K2 Studio. To successfully work through this tutorial, you should be familiar with K2 terminology and workflow concepts.
Why use Parent-Child Workflows?
Parent-Child Workflows are ideal in situations where you have multiple tasks that are not dependent on each other. For example, you might start child workflows if you have a process that requires action from multiple departments, yet those actions are independent of the other departments. Another example would be if your process contains a number of system events (such as updating lists) that are not dependent on other steps in the process. Child workflows can run at the same time, or one after another. The parent workflow must have some sort of closure however, from the child workflow so that it can continue and complete.
Workflow Design
In our basic parent-child vignette, we will create a new project in K2 Studio, then add two process items (the Parent Workflow and the Child Workflow). (Remember that the terms 'process' and 'workflow' are the same.) The Parent Workflow will consist of a single IPC (Inter-process Communication) event where K2 will fire a Child Workflow. The Child Workflow will send the originator a confirmation email that contains data it received from the Parent Workflow. After the Child Workflow email has been sent, the Child Workflow will be complete and K2 will return to the Parent Workflow. The Parent Workflow will then send an additional confirmation email that contains data it received from the Child Workflow. After the parent email is sent, the parent-child workflow process will be complete.
The diagram below illustrates our basic parent-child concept using a flowchart. Notice that there are two columns, one for the Parent Workflow steps and one for the Child Workflow steps. Notice that the Parent Workflow pauses while the Child Workflow is running. The Parent Workflow then resumes after the Child Workflow has completed.
Mapping out your workflow steps using a flowchart or similar diagram can help you to clearly visualize the events and steps necessary to accomplish your parent-child workflow goal.
There are five steps for completing this vignette. In Step 1, we will create a K2 Studio project and add two process items (the Parent Workflow and the Child Workflow). We will also add several data fields which we will use throughout the workflow to transfer data from the Parent Workflow to the Child Workflow and vice versa. In Step 2, we will add and configure the IPC event for the Parent Workflow. In Step 3, we will add and configure the email event for the Child Workflow. In Step 4, we will deploy the Parent-Child Basic project and assign workflow permissions and finally in Step 5, we will test our project.
Duration
This tutorial should take approximately 20-30 minutes to complete.
We begin with Step 1, creating the K2 Studio project and basic parent/child workflows.
We begin our tutorial by building the basic shell components necessary for the parent-child workflow. We will create a new K2 project and add the two workflows (the Parent Workflow and the Child Workflow). We will then add several data fields which will be used in later steps to transfer data from the Parent Workflow to the Child Workflow and vice versa.
Step 1 Tasks
- Create a new Project in K2 Studio and Name it
Parent Child Basic - Add a blank Process Item to the Project (for the Child Process) and Name it
Child Process - Add another blank Process Item to the Project (for the Parent Process) and Name it
Parent Process - Add a Data Field to the Child Workflow and Name it
Child Data Field - Add a second Data Field to the Child Workflow and Name it
Second Child Data Field
then make the Initial Value
K2 Learning! - Add a Data Field to the Parent Workflow and Name it
Parent Data Field
- Launch K2 Studio. (Start > All Programs > K2 blackpearl > K2 Studio)
Create a new project (File > New) with the following settings:
K2 Types: K2 Project
K2 Templates: K2 Project
Project Name: Parent Child Basic - Right-click the Parent Child Basic title and select Add > New project item.
- Create a new process with the following settings:
K2 Types: K2 Process
K2 Templates: Blank Process
Process Name: Parent Workflow - Repeat the steps above and create a New project item for the
Child Workflow - Begin by double-clicking the Child Workflow title so that it is the 'live' workflow. Click the Object Explorer pane or icon.
- In the Object Browser, first click the Process/Activity Data icon (A below), then expand the Data Fields node.
Right-click the Child Workflow Data Field node and select Add. - Name the data field
Child Data Field
then click OK. (Keep all of the default settings in place.) - Repeat the steps above and add a second data field to the Child Workflow. Name the second data field
Second Child Data Field
and give it an initial value of
K2 Learning!
then click OK. We will pass the Second Child Data Field value from the Child Workflow back to the Parent Workflow in a confirmation email. - Switch back to the Solution Explorer and double-click the Parent Workflow to make it the 'live' workflow.
- Once again, switch back to the Object Browser. Select the Process/Activity Data icon, expand the Data Fields node, then right-click Parent Workflow and click Add. For the new data field Name, enter
Parent Data Field
then click OK. - Save your project. (File > Save)
When the project is created, you will be directed to the Solution Explorer. We will now add a New project item to the project, which will be the Parent Workflow.
Your Solution Explorer should look like the image below.
Now we need to create data fields, one for the Parent Workflow and two for the Child Workflow. The data fields pass data from one workflow to the other. In our project, we will pass the Parent Workflow Originator's Display Name from the Parent Workflow to the Child Workflow. We will then use this value in a confirmation email. Then, we will pass a value (that we will set Manually) in the Child Workflow back to the Parent Workflow. We will again, use this value in a confirmation email.

Notice that the Child Workflow is the live workflow, which is evidenced by the title bar. (See the image below.) So, we will begin adding our data fields to the Child Workflow first. The first data field will 'receive' data from the Parent Workflow. The second data field will contain a value that we will manually input, then pass back to the Parent Workflow.
Now we will add a data field to the Parent Workflow. This data field will 'receive' the Second Child Data Field value from the Child Workflow. In the real world, you may or may not use this step exactly, but the intent is to demonstrate one method of transferring content from the Child Workflow back to the Parent Workflow via data fields.
Step 1 Review
In this step we created the Parent Child Basic project in K2 Studio, then added two project items, the Parent Workflow and the Child Workflow. To complete our basic project construction, we added a data field to the Parent Workflow and two data fields to the Child Workflow. The data fields will be used in later steps to transfer data from the Parent Workflow to the Child Workflow and vice versa.
In this step, we will add the IPC event that will interact with the Child Workflow. We will complete the Parent Workflow by adding an E-mail Event that will send a confirmation email to the originator indicating the Parent Workflow has completed.
Step 2 Tasks
- Add an IPC event to the Parent Workflow design canvas. For the Process, browse to and add the Child Workflow. Add the Process Folio as the Folio value and call the process using the Synchronous option.
- Keep the default Workflow Servers setting, and change the Authentication mode to Impersonate Originator.
- On the Process Send Field Mappings screen, map the Originator's Display Name property to the Child Data Field.
- On the Process Return Field Mappings screen, map the Second Child Data Field to the Parent Data Field.
- Change the DefaultActivity name to
Start Child Workflow - Add an E-mail Event to the design canvas (separate from the 'Start Child Workflow' activity. Name it
Email Parent Complete
then configure the Recipient as the 'Originator' and enter the following for the Subject line:
Parent Workflow Complete [Parent Data Field]
where the bracketed text is replaced by the Parent Workflow > Parent Data Field.
Enter any content you like for the Message Body.
- Still working with the Parent Workflow live, click the Event Wizards pane or icon, then drag an IPC Event onto the design canvas, just below the Start box.
- The IPC event wizard opens. Click Next on the home screen. On the Process, Folio and Type of Call screen, click Browse (for the Process), then select the Child Workflow. Click OK.
- Open the Context Browser for the Folio, then the Workflow Context Browser, then add the Folio property to the Folio field.
- Confirm that Synchronous is selected for the Select how to call the process option. Click Next when ready.
- On the Workflow Server Connection screen, keep the default Workflow Servers setting, then select Impersonate Originator for the Authentication Mode. Click Next.
- Integrated: Uses the K2 service account as the user attempting to start the IPC process.
- Basic: Uses the originator's credentials to start the IPC process. This option is only available if the IPC Process is located on the local K2 server.
- Impersonate: Uses the originator's credentials to start the IPC process.
- Expand the Context Browser, then the Workflow Context Browser. Drag the Originator's Display Name into the Child Data Field 'Value' field. Click Next when ready.
- On the Process Return Field Mappings screen, map the Second Child Data Field from the Child Workflow back to the Parent Data Field. (Recall that the Second Child Data Field has an initial value of 'K2 Learning'. We will use this data field in a confirmation email to demonstrate passing data from the Child Workflow to the Parent Workflow.) Click Next, then Finish to complete the IPC Event configuration.
- Double-click the DefaultActivity title and change it to
Start Child Workflow - Drag an E-mail Event onto the design canvas below the 'Start Child Workflow' activity.
- The E-mail Event wizard opens. Click Next on the home screen. Name the event
Email Parent Complete
then change the Recipient from 'Specify' to 'Originator'. For the Subject line, enter
Parent Workflow Complete for [Parent Data Field]
where the bracketed text is replaced by the Context Browser > Process/Activity Data > Data Fields > Parent Workflow > Parent Data Field. Click Next when ready. - Enter any text you like for the Message Body to indicate the Parent Workflow is now complete. Click Next, then Finish.
- Change the DefaultActivity title to
Final Workflow Step
then connect the 'Start Child Workflow' activity to the 'Final Workflow Step' activity. - Save your project (File > Save)
The Synchronous option will essentially pause the parent workflow while any child workflows run because the parent is expecting a response back from the child workflow(s). The parent workflow will resume after all child workflows have completed. The Asynchronous option is basically 'fire and forget' where the parent workflow will continue along because it is not expecting a response back from the child workflows. In this case, the parent and any child workflows run in parallel from the point where the child workflow was called.
For more information on Synchronous and Asynchronous configurations for IPC events, see the K2 Concepts - Synchronous and Asynchronous Events documentation.
Choosing the wrong Authentication Mode can cause errors later at runtime.
On the Process Send Field Mappings screen, notice the Child Data Field and Second Child Data Field properties. Recall in Step 1, these are the data fields we added to the Child Workflow. In this step, we are transferring data from the Parent Workflow to the Child Workflow. We will the use this data field in a confirmation email that will confirm the data transfer was successful.
Now, we are going to transfer data from the Child Workflow back to the Parent Workflow.
We will complete the Parent Workflow by adding an E-mail Event that will send the originator a confirmation email indicating the Parent Workflow is now complete.
Step 2 Review
In Step 2, we configured the IPC event to run synchronously, meaning the Parent Workflow will wait for the Child Workflow to complete before it resumes. We also configured the IPC event to pass data from the Parent Workflow to the Child Workflow (passing the Originator's Display Name) and then from the Child Workflow back to the Parent Workflow (the K2 Learning! value from the Second Child Data Field). Finally, we added an email event though not required, provides a clean end to our parent-child workflow.
The Child Workflow is very simple and consists of one system event, sending an email. What is significant here is that we will include the Second Child Data Field in the subject line of the email, which will effectively pass content from the Child Workflow back to the Parent Workflow.
Step 3 Tasks
- Add an E-mail Event to the Child Workflow. Name the event
Email Child Complete
then change the Recipient to the Originator. For the Subject line, enter
Child Workflow for [Child Data Field] Complete
where the bracketed text is replaced by the Child Data Field.
Enter an content you like for the Message Body.
- In the Solution Explorer, double-click the Child Workflow so that it is the active workflow.
- Click the Event Wizards pane or icon to expose the wizards. Drag an E-mail Event onto the design canvas, just below the Start box.
- The E-mail wizard opens. Click Next on the home screen. Name the event
Email Child Complete
then change the Recipient from 'Specify' to 'Originator'. For the Subject line, enter
Child Workflow for [Child Data Field] Complete
where the bracketed text is replaced by the Context Browser > Process/Activity Data > Data Fields > Child Workflow > Child Data Field. Click Next when ready. - Enter any content you like for the Message Body to indicate the Child Workflow has completed. Click Next, then Finish.
- Connect the Start box to the DefaultActivity activity. (Right-click inside the Start box and hold+drag down into the DefaultActivty activity.)
- Save your Parent Child Project (File > Save)
Step 3 Review
In this step, we added a single system task that will send an email on behalf of the Child Workflow. We included the Child Data Field in the email Subject line. In a previous step, we mapped the originator's display name to the Child Data Field and as such, we should see this variable passed from the Parent Workflow to the Child Workflow in the email Subject line.
The final steps we need to take before we can test our project is to deploy the process to the K2 server, then assign permissions (or Process Rights) in K2 Workspace.
Step 4 Tasks
- Deploy the Parent Child Basic project.
- In K2 Workflow, assign all Domain Users Start and View rights for the Parent Workflow and the Child Workflow.
- Deploy the Parent Child Basic project (File > Deploy) You will first see the 'Build In Progress' status bar, then the Deploy Project Wizard will launch. Click Next, then Finish. Now you will see the 'Deploy In Progress' status bar. When the deployment has successfully completed, the status bar will disappear and there will be a 'Deployment Succeeded' message in the K2 Studio status bar (in the lower left corner of your screen).
- Launch K2 Workspace. (Start > All Programs > K2 blackpearl > K2 blackpearl Workspace)
- Access the Management Console. Expand the K2 server (your server name may not be the same as the screen shot) > Workflow Server > Processes > then Parent Child Basic. (If you are new to K2 Studio, this is the project we just deployed. The workflow/process will not show up in K2 Workspace until it has been deployed.)
- Notice Parent and Child Workflows are listed under the project name. Expand the Child Workflow node, then click on Process Rights. The Process Rights pane loads. By default, K2 will add the user who deployed the workflow to the Process Rights as an Administrator for that Process. Click Add, then search for
Domain Users
then select the group and click OK. - CHECK the Start and View boxes, then click Save.
- Notice now, that the Domain Users have been added to the Process Rights pane for the Child Workflow. Click Save once again to complete this configuration.
- Using the same steps as above, add the Domain Users to the Parent Workflow, again with Start and View rights.
Now we are ready to switch over to K2 Workspace and assign permissions, or Process Rights.
(If you do not see the K2 blackpearl Workspace link in All Programs > K2 blackpearl, contact your K2 Administrator for the URL to K2 Workspace. If you are not a K2 Administrator, you may not be able to perform all of the steps. Ask your K2 Administrator for assistance if necessary.)
Step 4 Review
In this step, we deployed our Parent Child Basic project to the K2 server. We then assigned Start and View permissions to all Domain Users for both the Parent and the Child Workflows.
At this point, we are ready to test our Parent Child Basic project and see it in action! We will kick off the Parent Workflow from K2 Workspace, then observe the Parent Workflow and Child Workflow behavior using the View Flow report.
(Generally speaking, a workflow would start when a form has been submitted. In our case (since we didn't add any forms) we will start the process instances manually from K2 Workspace.)
Step 5 Tasks
- In K2 Workspace, start an Instance of the Parent Workflow. Instead of the Date, enter the following for the Folio value:
Parent Basic Started - Open the Process Overview report and observe that the Parent Workflow and the Child Workflow Processes are shown.
- Open the View Flow report for the Parent Workflow and observe the workflow has completed. Open the View Flow for the Child Workflow and observe that workflow is also complete.
- Confirm there are two email confirmations in Administrator's Outlook.
- Child Workflow for [Originator's Display Name] Complete
- Parent Workflow Complete for K2 Learning!
Notice that our Child Data Field value has been passed to the Parent email (K2 Learning!) and the Parent Data Field value has been passed to the Child email (Originator's Display Name).
- Click on Instances found under the Parent Workflow node.
- The Instance pane loads. Click Start New to fire off a new instance of the Parent Workflow process. When the Create a new Process Instance screen appears, UNCHECK the Use Date option for the Folio and enter the following to indicate this is the Parent Workflow Folio:
Parent Basic Started
then click Start. - Click the Home button to return to the K2 Workspace landing page. In the Reports pane, double-click the Process Overview report. (It may take a minute or so to open. If it appears to be doing nothing, wait a minute or so.)
- Notice the Process entries for the Child Workflow and the Parent Workflow. (You may have other workflows listed as well, we are just working with the Parent and Child Workflows.)
- Click the Parent Workflow to open the Process Instances. Click the View Flow icon to open the View Flow Report for the Parent Workflow. Notice the Parent Workflow has completed. Close the View Flow Report.
- Use the green back-arrow to return to the Process Overview screen, then open the Child Workflow View Flow report. Notice the Child Workflow has completed. Close the View Flow Report for the Child Workflow.
- Open Outlook for DENALLIX\Administrator (Start > type Outlook) (If you get a message about syncing CRM, let it complete. If you get a message about licensing, click Close to continue.)
Notice now, that an instance of the Parent Workflow appears in the Instances pane.
Click on the Instances option for the Child Workflow. Notice there are no entries. This is because our Parent and Child Workflows have already completed. In the real world, your Child Workflows would likely contain user tasks and system tasks. System tasks process very quickly. User tasks however, would likely show up in the Child Workflow Instances pane as they wait for the user action to take place.
In the final steps for testing our parent-child workflow, we will open the Process Overview and View Flow reports.
Now we will take a look at the confirmation emails that have been fired off. There should one email indicating the Child Workflow has completed and one email indicating the Parent Workflow has completed. We also want to confirm the data transfers from the Parent Workflow to the Child Workflow and vice versa.
You should see two confirmation emails. The Child Workflow confirmation should show the display name of the workflow originator in the Subject line. If it does, this confirms that the Parent Workflow passed the display name to the Child Workflow via the Child Data Field.
Example of parent to child data transfer
The second email will be the Parent Workflow confirmation and should show the Initial Value that we entered for the Second Child Data Field. If it does, this confirms the Child Workflow passed the data field value to the Parent Workflow via the Parent Data Field.
Example of child to parent data transfer
Step 5 Review
If your confirmation emails are correct, then congratulations! You have successfully created a parent-child workflow. If you are ready to move on to an intermediate-level parent-child tutorial, continue on to the Parent-Child Workflows (Intermediate) tutorial. The intermediate tutorial will guide you through creating a parent-child workflow with multiple child workflows and destinations.