How to set task local variables when starting the plan item?

I’m trying to start a human task with some system-managed variables. I’ve tried to do with plant item transition builder but probably fail to understand what kind of variables childTaskVariables does set, because seems those aren’t persisted into the act_ru_variable table so I cannot use for search query API.


I’ve ended up doing this by starting a human task plan item, then retrieving searching it, and then setting variables via task service.

Task task = cmmnTaskService.createTaskQuery().planItemInstanceId(request.getPlanItemInstanceId()).singleResult();
cmmnTaskService.setVariablesLocal(task.getId(), mapToVariables(request));

But that seems like the wrong way to do it. I would prefer to create a task with variables in one step or at least under some kind of transaction. Any way to achieve this in a “cleaner” way?

Hey @struggzard,

The childTaskVariables are meant for CMMN Tasks that start child instances, such as Case and Process Task.

What you could try to use is the localVariable. This will set variables locally on the PlanItemInstance (which is a parent for the User Task).