Is it possible to filter Task and Process by check if a variable exist or not using the REST API

Hi,
In our system we have a created usertask in Camunda that require a user to assign someone to do a task. In a separate page of our application we pull all usertask that are an assigment task and that has been completed (finished) to be able to see when the assignment has been completed and to whom is now in charge for the next part of the process. But we now can cancel process and don’t want to retrieve it so we have added the Process variable : CANCELLED.

So we now can filter out all usertask (assignment or not) that come from a process that has been cancelled : /history/task?processVariables=CANCELLED_eq_false

but now all previous task are not retrieve anymore, so we didn’t have any choice but to go in the camunda database and add manually the variable to all previous process.

Is there something like cancelled : /history/task?processVariables=CANCELLED_nexist

Anyone having any ideas ? Is it a missing feature ?

Anyone having any ideas ? Is it a missing feature ?

Hi,
There is no option to filter for variable existence. I can’t think of perfect solution but may be one of these options will work for you or give you an idea:

  • If those task can be divided by their start date, you can filter for task’s startedAfter query parameter and combining results of two separate requests
  • You can filter tasks by specific processInstanceId. To find processInstanceId you can query process instances again by startedAfter query parameter.
  • You can filter by processInstanceBusinessKeyIn parameter if you use business keys or set busines keys instead of adding variables.
  • Or write your own api using HistoryService-> createHistoricTaskInstanceQuery which is more flexible and you can find more ways to filter.