Filter created in the backend for a TaskList only displays after refresh

Hi there,

I have this code, which is doing it’s work right after the start form is ‘Complete’ in the model.

FilterService filterService = delegateExecution.getProcessEngineServices().getFilterService();

TaskQuery myTasksQuery = delegateExecution
                .getProcessEngineServices()
                .getTaskService()
                .createTaskQuery()
                .executionId(delegateExecution.getId());

 Filter myTasksFilter = filterService.newTaskFilter("Case Nr");
 myTasksFilter.setOwner(userId);
 myTasksFilter.setQuery(myTasksQuery);

 Filter filter = filterService.saveFilter(myTasksFilter);
 List<Task> tasks = filterService.listPage(filter.getId(), 0, 20);

Filter is visible in the Task List but is only visible after I do refresh in the Task List. Is it possible to somehow make it appear as soon as the form is submitted?

Maybe an alternative solution would be to do it in the frontend?

Thanks and kind regards,
Deniss

Hello,

Maybe somebody from the camunda team can offer a small insight on what I am doing wrong? Or maybe there is another parameter which makes the filters appear without ‘refresh’?

Thanks in advance.

Kind regards,
Deniss

@sebastian.stamm Hi Sebastian,

Maybe you can assist when you have time? Thanks and kind regards,
Deniss

Hi Deniss,

creating a filter as a result of a start-form is not a common scenario to my knowledge. Therefore, the list of filters is not updated when a start-form is submitted.

However, you can force tasklist to update the list of filters by calling:

angular.element('[ng-view]').scope().tasklistData.changed('filters');

in the submit-success lifecycle handler of your start-form.

Does that work?

Cheers
Sebastian

2 Likes

@sebastian.stamm
worked like a charm! Thank you :slight_smile: