Worklist criteria filter not working when order of added filters change.


Badge +1

I'm seeing some wierd behaviour with how the client api's WorklistCriteria filters a worklist. I suspect it is a bug. We have to cater for many different scenarios so we have to dynamically generate our filters. We are using 4.12060.1560.0 and I did find http://help.k2.com/KB001588 which did state that filters on DateTime instances does not work which could the problem but I'm not sure. To the problem:

 

I'm trying to filter item (this is heavily dumbed down) with the following query:

 

WorkflowName = "some name" && (SystemWaitTime < Date || SystemWaitTime == NullDate)

 

When I'm using the following filter setup it works:

 

            criteria.AddFilterField(WCLogical.And, WCField.ProcessData, "OVWorkflowName", WCCompare.Equal, Helper.TestWorkflowName);
criteria.AddFilterField(WCLogical.And, WCField.None, WCCompare.Equal, null);
criteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null);
criteria.AddFilterField(WCLogical.And, WCField.ProcessData, "OVSystemWait", WCCompare.Less, new DateTime(2014, 6, 10, 6, 41, 10, DateTimeKind.Utc));
criteria.AddFilterField(WCLogical.Or, WCField.ProcessData, "OVSystemWait", WCCompare.Equal, K2Constants.FieldDatetimeNull);
criteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null);

 when I use this, it breaks (returning more items than it should):

criteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null);
criteria.AddFilterField(WCLogical.And, WCField.ProcessData, "OVSystemWait", WCCompare.Less, new DateTime(2014, 6, 10, 6, 41, 10, DateTimeKind.Utc));
criteria.AddFilterField(WCLogical.Or, WCField.ProcessData, "OVSystemWait", WCCompare.Equal, K2Constants.FieldDatetimeNull);
criteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null);
//criteria.AddFilterField(WCLogical.And, WCField.None, WCCompare.Equal, null);
criteria.AddFilterField(WCLogical.And, WCField.ProcessData, "OVWorkflowName", WCCompare.Equal, Helper.TestWorkflowName);

 The only difference is our search by workflow name. It breaks when it is the last thing to compare as if it is being ignored.

 

Is there a different way to do something similar that will work? I tried to use the Management API's WorklistCriteriaFilter but could not see a way to filter by ProcessData which is kind of critical for us. We are trying to avoid sending back too many items from the k2server as it will affect our performance negatively and our actual query is a lot more complex than this.


2 replies

Badge +1

I was hoping for something different. Now I'll have to open a ticket. Thanks

Badge +13

Below doesn't work 4.6.7:  (hope this will save someone hours of troubleshooting)


StartBracket
PocessFolder, Equal
Or ProcessFolder, Equal
EndBracket
And
StartBracket
Folio, Like <---- additional filter before it
Or ProcessXML Field LIKE <--- does not filter on ProcessXML
End Bracket

-----------------------------------------------------------------------

From K2 Support:  At the moment, the WorklistCrtieria does not support this type of logic, see below:

The OpenWorklist method first filters all normal process fields (in SQL first - because it is available as separate SQL columns: like folio, StartDate, FinishDate etc.) and returns a result set, which then filters all the data/xml fields that are specified to the process instance. It has been done this way, because the data and/ xml fields are stored in binary archiveX encrypted packets and SQL isn't really sure how to decrypt that. In this case, if we filter on ProcessFullName (first filter from the SQL side to get specific process instances) and ProcessData (from the K2Server Side), the method will do a call to SQL with only the ProcessFullName filter parts in it... SQL will then return the results and these are the results that will then get filtered for ProcessData and ProcessXML on K2 server(s).

A working example as follows:
a. If you use ProcessFolio (SQL side) AND ProcessDate (from the K2Server side), it should work because the ProcessFolio will bring back the process with the filtered Folios and then continue to filter out the datafields (this will worked correctly)
b. BUT, ProcessFolio OR ProcessData will not work as expected because it brings back the Filtered Folios, but then the OR is useless because it does not have the other Processes without the Folio to check the datafields

So if you only do the Data/XML field filtering in 1 WorklistCriteria Object - it should work, but if you mix DataXML with normal Process fields, the logic does not work. This is something that has been logged by the Labs Support Team.

Currently there is not a fix for this issue as there are some HUGE changes in our current logic and possibly even our architecture, in order to fix this. This is also something that I will log as a known issue in our documentation.

The proposed work-around, is if you need to filter on data or xml - those values should be externalized to SmartBox or other SmartObjects - not workflow fields. This is because there will be a huge performance impact otherwise, and this is something we obviously would like to avoid. Since these are stored in encrypted packets, reading everything in and decrypting EACH WorklistItem in order just to inspect the value, will take its toll on performance.

Reply