Reading the VariableTyped POJO from human task of CMMN process

I have created a Rest service to read the variables of a Human Task of a sample CMMN process.

VariableMap variables = Variables.createVariables().putValue(“createdBy”, “user1”)
.putValue(“pojo”, new JavaPojo(“arg1”, “arg2”));
CaseInstance caseInstance = processEngine.getCaseService().createCaseInstanceByKey(“Process_Name1”,variables);
I do have 2 tasks in the CMMN process diagram.Both the human task’s are configured to start manually.
Here the snippet that I am using to start and assign the human task to a user.
List tasks = processEngine.getTaskService().createTaskQuery().caseExecutionId(caseExecution.getId()).list();
if (tasks.size() > 0) {
selectedTask = tasks.get(0);
processEngine.getTaskService().claim(selectedTask.getId(), “demo”);

Till this point things are good.

I would like to edit the process variables for that task and reinject them into process.
For that I tried to get the process varaibles like this.

List tasklist = taskService.createTaskQuery().taskAssignee(“demo”).list();
String createdBy = (String) runtimeService.getVariable(task.getCaseInstanceId(), “createdBy”);

This code snippet is giving me a null pointer exceptions saying “execution id is null”.
I had a look at my mysql schema for the table called “act_ru_task”, there I can see the execution_id_ column as null.

Am I doing right here? How to get the POJO that I have in different human tasks , edit the values and pass as input to other human task?

Hi @subbu,

Could you please share the entire stacktrace?



BTW, you have to use for CMMN the CaseService and not the RuntimeService to retrieve the variable from the case instance. So, it should be something like this caseService.getVariable(task.getCaseInstanceId(), "createdBy");.


Hi Roman,
Thanks for the Quick response. using caseService instead of RuntimService Worked well.