Can I find the task related to an item

  • 21 September 2018
  • 3 replies
  • 2 views

I have a list view with instances of my business object (report instances). These are coming from our own SQL db. These items run through a workflow. A person has two lists. 1: Worklist (all his tasks) with to these tasks attached a report instance; 2: A list of all Report instances. 

 

I would like to support the following scenario: 

A user opens an item from the Report Instances list. Check whether this item has currently send out a task to the user who opens this item, so he is able to action the item from here. 

 

What I would need is: 

Find the tasks assigned to the user, where the related workflow of the task has input variable InstanceID=Value of parameter InstanceID. 

 

Does anyone know how to retrieve the task serial no based on user and variable value?


3 replies

Userlevel 5
Badge +13

This is possible using the K2 Management API - my suggestion would be to have the folio of your tasks be the report instance Id (if possible) so that can be a highly visible link between K2 worklist items and your SQL db records. Then you can use the API to get all worklist items for a particular folio and iterate through them until you find one that has the destination equal to the current user. That worklist item will have their personal serial number.

Changing the folio to a GUID doesn't feel like a good idea, because the folio is the for the end user recognizable description. Changing this would mean he gets a list of guids in his task list. Bad idea.

 

Is it possible to do it through finding for example a certain substring in the worklist item URL?

Userlevel 5
Badge +13

Yes, I can think of a couple of other ways to do this if the folio can't be the join - you can use the workflow client API to get all of the tasks for a user, and iterate through them and use the workflow management API to get the process data for each one. When you find the match, then the serial number on that one will be the user's task.

When you kick off the workflow, you would put the report ID into a data field on the process instance instead of the folio. It won't perform as well, but if users have only a couple dozen tasks (as opposed to hundreds) it should still be ok.

Reply