+44(0)1908 545 770
YOUR EXPERT RPA PARTNER

Team up with our RPA strategy and tech specialists for maximum automation impact

Find out more
Harness the power of UiPath in your business.
WATCH NOW

Save money and spend more time on priority work.

Book consultation
READY, SET, AUTOMATE

Let's choose, design and deploy a process automation solution for your business.

Find out more
TRANSFORM YOUR BUSINESS

Let's analyse your business to discover opportunities for innovation and automation.

Find out more

Begin your business transformation journey

Book consultation
AUTOMATE EVERY FUNCTION

Automate where it matters most. Scale to solve challenges in every area

Find out more
GIVE EVERY TEAM THE TOOLS FOR SUCCESS

Equip people with user-friendly solutions that save time and make work easier

Find out more

Which business problem
can we solve first?

Book consultation
12 November 2016

How to use the Plan per slot (No destination) in a K2 IPC to start multiple process instances

In this blog, we will show how to use the “Plan per slot (No destination)” feature in K2 to loop through a list of items and execute a set of events for each item in a K2 workflow – this is a pattern required for older versions of K2.

K2 Automated Testing Software

rnBenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.

 

Free K2 Five Upgrade Review

 

 
The previous versions of K2 don’t have the for each functionality, and this blog will illustrate how to loop through items in a K2 workflow.

We will use a simple leave request process to illustrate the solution.  Each employee has a number of leave days, and when the New Year starts, they gets a number of days for the year.

Here is an example of a business policy for leave allocation –

  • Employed at company for less than 5 year = allocated 20 days
  • Employed at company for more than 5 year = allocated 25 days

We will assume a database table exists that has the employee’s details and their allocated leave totals.

Let’s create the solution –

First we need to create the SmartObject that will retrieve the data and make this available in the K2 workflow as part for a “Get List” SmartObject method.

1 - Employee SmartObject 1 – Employee SmartObject

Let’s assume we need to create a workflow instance for each of the records above.  We will use a K2 IPC event to start a process instance for each of these records.  We will have a parent K2 workflow that will instantiate multiple instances of a child workflow process.   To do this –

Create a parent K2 workflow process named EmployeeWF and add the following data field

  • EmployeeID

2 - Employee Parent Process 2 – Employee Parent Process

Create a child K2 workflow process named LeaveDayUpdateWF with the following data fields –

  • EmployeeId
  • Age

3 - Employee Child Process 3 – Employee Child Process

In the EmployeeWF, change the destination rule in advance mode.  Set the destination rule option to “Plan per slot (No destination)”.  This will allow us to start an instance of each item from the SmartCbject GetList method.

Ensure the ID is selected from the SmartObject Get List method

4 - Destination Rule Configuration 4 – Destination Rule Configuration

Click Finish.

Next, let’s configure the IPC event that will call the child workflow process – this will happen for each result returned in the Get List SmartForm method –

Select the process name and set the folio.  The value of the “ID” will be available in the ActivityInstanceDestInstanceData K2 context value and can be used to create a meaningful folio number.

5 - IPC Event 5 – IPC Event

Again, the Employee ID is available in the ActivityInstanceDestInstanceData K2 context, so this value can be passed into the child workflow process.

6 - IPC Data Mapping Fields 6 – IPC Data Mapping Fields

To configure the parent process to wait until all the child process instances are completed, configure the succeeding rule to ensure that all the instances have completed.

7 - Succeeding Rule 7 – Succeeding Rule

In summary, the blog shows how to use an alternative way to loop through a set of items retuned by a K2 SmartObject Get List method and start a process instance for each; waiting for all instances to complete before the parent continues.

Need further technical advice or support?