How to view the process variables of completed tasks with the History Service?

Hi, I’m new to Flowable and would like to know if there is a way to view the process variables from completed tasks. I tried using the History Service to view the variables but was unable to view the variables.

I referenced the holiday request example program and tried to modify that code to view the variables.
Here’s the relevant code.
relevantcode

Here’s the output that I got (I made and completed a few tasks and ran the above code to see if I could view the processVariables for the completed tasks)

Found 9 tasks
{}
{}
{}
{}
{}
{}
{}
{}
{}
Done

Am I going in the right direction with this code? What should I be doing differently to view the contents of the completed tasks?

You have to explicitly request the variables if you want to use them.

The HistoricTaskInstanceQuery the query returned by historyService#createHistoricTaskInstanceQuery() has methods called includeProcessVariables() and includeTaskLocalVariables() If you do that then you would be able to see them in your call.

Cheers,
Filip

Thank you! That worked perfectly.