Retrieve current task from variable value

Hi,

I have a user task, say, BackupAssignmentTask.
I’m storing a DTO in my process variables, assignmentDTO, which has id in it.

I have a REST api, which passes assignmentId as a parameter and I want to fetch the task by task definition and process variable which has assignmentId equals to the passed assignmentId.

Is there any way I can achieve this using taskService.

Thanks

I have tried below. in 2nd log, I get empty list, in third log, I get all the task. But i want specific task which matches my assignmentId.

public void closeAssignmentBackupAcknowledgeUserTask(Long assignmentId) {
        log.debug("Completing the user task backup acknowledge for the assignment {}", assignmentId);
        log.debug("Task is {}", taskService.createTaskQuery().processVariableValueEquals("assignmentProcessDTO.assignmentDTO.id", assignmentId).list());
        log.debug("task with def key {}", taskService.createTaskQuery().taskDefinitionKey("ccAcknowledgesBackup").list());
    }

Hi @ash6892,

as complex variables are stored in a blob field in the database, you cannot search for attributes of these objects: https://docs.camunda.org/manual/7.12/user-guide/process-engine/variables/#supported-variable-values.

If you want to identify the process instance (or task) with a certain assignmentId, you have to store the ID in a separate variable.

Hope this helps, Ingo