Solved

Search active workflows for specific stage

  • 26 July 2018
  • 7 replies
  • 39 views

I was wondering if anyone knows of a way to check all active workflows and find which are on a specific workflow activity.

e.g. I have a workflow with three activities 1,2,3 and I want to find all active workflows that are currently waiting on activity 2

 

Is that possible? I suspect there'd be some sort of record in the K2 database but I'm not sure if theres anything I could query

icon

Best answer by tbyrne777 26 July 2018, 17:31

View original

7 replies

Userlevel 5
Badge +13

Hi - it depends on what you mean by "Stage"... is it a particular task? Activity? Sub-process? Other?

Sorry I think activity is the correct word to use

Userlevel 5
Badge +13

Ok, there are a couple of different ways to do this... thee is the "Activity Statistics" report and the "WorkLists" section under the Management Console (K2 Workspace). I tend to use the WorkLists section as it is faster than the report, does that help?

So using the worklists section helps a bit since I can filter by activity name. Though if I wanted to check only 5 specific process instances would that be possible?

 

so like select * from sometable where actvity name like 'activity 2' and process instance id in (1,2,3,4,5)

 

if the worklist page can pull up the information then surely I should be able to find it within the k2 database no?

 

Userlevel 5
Badge +13

Oh, sure, if you want to query the K2 database you could do something like this (you'll have to tweak it a bit but this can get you started):

SELECT pset.name, a.name

FROM serverlog.procinst pi

JOIN server.[proc] p ON p.id = pi.procid

JOIN server.[procset] pset ON pset.id = p.procsetid

JOIN serverlog.actinst ai ON ai.procinstid = pi.id

JOIN server.act a ON a.id = ai.actid

 

took a while to understand what each table is for but I made sense of it in the end and I kind of query I wanted. Thanks a lot!

 

did something like this

 

SELECT pi.Folio, pi.ID, ai.status

FROM k2.server.procinst pi

JOIN k2.server.[proc] p ON p.id = pi.procid

JOIN k2.server.[procset] pset ON pset.id = p.procsetid

JOIN k2.serverlog.actinst ai ON ai.procinstid = pi.id

JOIN k2.server.act a ON a.id = ai.actid
where pset.ID = 1 and p.id = 7 and ai.ActID = (whichever activity I want to search for) and pi.id in (put process instance ids here)

 

I also changed the k2.serverlog.procinst to k2.server.procinst, does it make a difference though?

 

Userlevel 5
Badge +13

The tables in the serverlog schema contain all items whether they are active or not. The server schema tables are only active items. I tend to use the serverlog tables to be comprehensive.

Reply