Camunda Team Blog

Introducing Task Filters

Written by Daniel Meyer on , under Execution category.
With Camunda BPM 7.2.0-alpha5, we introduce Task Filters. Task filters are TaskQueries which can be saved to the database so that you can run them repeatedly.

Creating a Filter using Java API


At a Java API Level, a filter can be created as a regular task query:
// create a taskQuery
TaskQuery myTasksQuery = taskService.createTaskQuery().taskAssignee("daniel.meyer").active();

// save taskQuery as filter
Filter myTasksFilter = filterService.newTaskFilter("My Tasks");
myTasksFilter.setOwner("daniel.meyer");
myTasksFilter.setQuery(myTasksQuery);
String filterId = filterService.saveFilter(myTasksFilter);
 
// execute the filter
List<Task> tasks = filterService.listPage(filterId, 0, 20);

If you want to share the filter with other users and for each user, make should return that particular user's tasks, it is possible to use Expression Language in the task query:
taskService.createTaskQuery().taskAssigneeExpression("${ currentUser() }").active();
The above example uses the built-in expression currentUser() which returns the userId of the currently authenticated user (set through IdentityService.setAuthentication()).

For more built-in Expression Language functions, see the corresponding User Guide Section.

Filters can also be managed using the REST Api.

Managing Task Filters in camunda Tasklist

With the latest release of camunda Tasklist, you can manage filters. Filters are displayed at the left handside of the tasklist and can be assigned a Name, a Priority and a Color.

Creating a new Task Filter

A new filter can be created by selecting the "New filter" button. A dialog opens which allows to configure the filter:


Defining Filter Criteria

Filter criteria can be defined in the "Criteria" section. In this example we select all tasks by candidate Group and Due Date:

Sharing Filters

Filters can be shared with other users and Groups by defining Authorizations. This filter is shared with all users part of the group "management". They have been granted "READ" permission meaning that they can see and execute the filter but they cannot modify or delete it.

What's next?

With Camunda 7.2 we limit out of the box support for filters to Task Filters. If this is a success, we can think of many more interesting usecases for filters:
  • camunda Cockpit: Process Definition and Process Instance Filters in cockpit
  • Operations Monitoring: define a Filter Query and monitor it via REST from an Operations tool like Nagios
  • Combine Filers and Timer Jobs: At midnight, execute a Filter and for each Task, send a reminder email...
  • ...