We are creating an app (HTML/Javascript) to list user tasks. The app shows some task fields, like name or dates. We also want to display some variables in that list. The app gets the task list via Rest API filtered by some fields.
Is there a way to fetch a task list with its own variables via Rest or JAVA API?
@pmanu93 at present you have to make two api calls to get the variables, one is for fetching tasklist and another call is for fetching variables for those tasks.
If you are interested in fetching tasks and variables in one call, then you can write a native query to fetch in one api call.
This rest controller gets the list of tasks for current user: val taskList: List<Task> = taskService.createTaskQuery().taskAssignee(principal.id).list()
Make a list of task ids: val taskIdList = taskList.map { it.id }
Get a list of variables for there task ids with concrete name (taskDetails) val varList = runtimeService.createVariableInstanceQuery() .taskIdIn(*taskIdList.toTypedArray()).variableName("someVariableName").list()
Write variable values to corresponding task instances - to variable “description”
I find it odd that such a solution is required given that Activiti’s api (5.21.0) allows one simply return tasks and variables together with List<Task> tasks = query.includeProcessVariables().list();
I had thought Camunda forked from Activiti after 5.21.0, which would indicate this functionality was deliberately removed. I have to wonder why. There’s nothing wrong with your workaround, I just wonder why it’s necessary.