+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
30 October 2015

How to improve K2 worklist performance using caching

K2 improving performance

The K2 worklist is used to expose tasks to users that participate in workflows.  There is one K2 worklist, but it is exposed in several ways.  In essence, it is exposed as a user interface that calls the System.Workflow.Client object to retrieve worklist items from the K2 server.

K2 Automated Testing Software

BenchQA 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 out-of-the-box worklist items are workflow centric only – ie. it only displays data relating to the process instance.  It is typically required to merge this data with business data.  This makes the worklist more meaningful and provide good context to the user i.e. if an order amount is displayed and a customer account name, users might prioritise work based on this rather than the age of the item.

The easiest way to implement such a worklist is to create a custom service broker.  This does 3 things in essence –

  1. Load the worklist data
  2. Load the business data
  3. Join the data together

The implementation of this service object is beyond the scope of this article, but what I want to show is to implement caching.

The pattern for the implementation of the worklist custom service broker I had to provide caching for is a follows –

  1. Use the SourceCode.Worklow.Client object and load the users worklist
  2. Loop through each item and add the worklist data to the dataset that the service object returns
  3. For each iteration of the loop, load the business data and add it to the dataset
  4. Return the dataset

The call in item 3 needs to be cached and the subject of this post.

The first thing is to call the metadata lookup in the loop.  This actually has 3 methods that loads data from separate sources.  I will run through the DueDate caching

k2 improving performance

1 – Worklist Item loading with metadata

The results of the methods are saved in a new list.  The calling code unpacks this and adds it to the returning data table.  Notice the DudeDateLookup method is called.

k2 improving performance

2 – Defining a metadata list to return to Worklist Item

This will happen for each worklist item, but the 2nd time round the items will be cached.

The code below implements the caching

k2 improving performance

3 – Lookup with caching mechanism

The concept of a due data is wrapped up in a due date class with a DueDate data class (1)

The cached list of due dates are kept in a static class (2) and is instantiated in (3) when the method is first called.  This is where new ones are added to the cache, or existing ones retrieved but only if they haven’t expired.

(4) is where we actually retrieve data from the cache, providing it hasn’t expired.  If data is not found in the cache, we load it again (8).  (6) just removes the expired version to avoid duplication.

(7) actually implements the cache expiration window.  This is how long the item will be valid for in the cache before it is flushed from the cache.

As mentioned, this method was to fix a performance issue in an existing custom worklist.  An alternative is to cache the business data and “join” this to the worklist data.]

Need further technical advice or support?