SearchOptionsBuilder and sort parent fields

1
0
-1

Hello. This is my SearchOption :

  1. SearchOptionsBuilder sob = new SearchOptionsBuilder(0, 100);
  2. sob.sort(ActivityInstanceSearchDescriptor.ACTIVITY_TYPE, Order.ASC);
  3. SearchOptions so = sob.done();

When I call

  1. result = searchMyAvailableHumanTasks(userId, so).getResult();

I get error :

  1. org.bonitasoft.engine.exception.SearchException: USERNAME=admin | org.bonitasoft.engine.persistence.SBonitaSearchException: Invalid sort key: activityType

The problem is that searchMyAvailableHumanTasks() returns HumanTaskInstance which is subinterface/subclass of ActivityInstance and I can't sort by any parent field and I can only sort by fields defined in HumanTaskInstanceSearchDescriptor.

Is there any trick to sort by parent fields or it is impossible and only way to sort is by collection sort (code) ?

1 answer

1
+1
-1

Hi,

The filter / sort options you use must be valid with the search method you call. For instance, to search for HumanTaskInstance's, you must call ProcessAPI.searchHumanTaskInstances(), and in the SearchOptions parameter, you can only use filters / sort options from class HumanTaskInstanceSearchDescriptor

On the same pattern to search for ActivityInstance's, you must call ProcessAPI.searchActivities(), and in the SearchOptions parameter, you can only use filters / sort options from class ActivityInstanceSearchDescriptor

Hope this helps, Emmanuel.

Notifications