TaskQuery problem

We have a problem selecting tasks for which users in the given group are candidates.

Code in a Tasklistener:
taskList = ProcessEngines.getDefaultProcessEngine().getTaskService().createTaskQuery().taskCandidateGroup(group).list();

I can see the group name in the DelegateTask.getCandidates().

Any ideas ?

thanks

Dieter

In the first step, we used the REST API and we had no problems to get the Tasklist for each group.

Dieter

Short Update,

even this short code does not work…

@Named(value = “EkTaskListener”)
public class EkTaskListener implements TaskListener {
@Override
public final void notify(final DelegateTask delegateTask) {
Task myTask =
ProcessEngines.getDefaultProcessEngine().getTaskService().createTaskQuery().
taskId(delegateTask.getId()) .singleResult();

    if (myTask == null) {
        System.err.println(">>>> EkTaskListener: TaskQuery returns null");
    }

— rest od code is snipped —
}

What is your initial goal, why do you want to fetch the tasks with candidateGroup in a TaskListener?

This is just for Debug Infos. Main Problem is, why the task with the task id is NULL

Regards

Dieter

Based on your model the task might not yet been in the database at this point in time.

OK, but how do I get the task information from the delegateTask ?

@Override
public final void notify(final DelegateTask delegateTask) {

    Task myTask = ProcessEngines.getDefaultProcessEngine().getTaskService().createTaskQuery().taskId(delegateTask.getId())
            .singleResult();

    if (myTask == null) {
        System.err.println(">>>> EkTaskListener: TaskQuery returns null");
    }

}

@langfr - Same model with the REST API no probelms

I tried to reproduce your problem, but without success.
I added this to a user task:
image
CamundaTaskListener is

package biz.mbisoftware.fn.ejb.session.camunda;

import javax.inject.Named;

import org.camunda.bpm.engine.ProcessEngines;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.TaskListener;
import org.camunda.bpm.engine.task.Task;

@Named
public class CamundaTaskListener implements TaskListener
{
    @Override
    public void notify( final DelegateTask delegateTask )
    {
        Task myTask = ProcessEngines.getDefaultProcessEngine().getTaskService().createTaskQuery().taskId( delegateTask.getId() ).singleResult();
        if ( myTask == null ) {
            System.err.println( ">>>> CamundaTaskListener: TaskQuery returned null!" );
        } else {
            System.out.println( ">>>> CamundaTaskListener: TaskQuery found " + myTask.getName() );
        }
    }
}

The task is found always.
What are you doing differently?

Hi,

out listener looks different. I have spoken with Falko from Camunda and he recommended to use a Delegate Expresseion

Regards

Dieter

my result

11:02:01,984 ERROR [stderr] (default task-4) >>>> CamundaTaskListener: TaskQuery returned null!

JavaClass or DelegateExpression make no difference for me.
But the Event type makes a difference. Using create the result is null, using assignment the result is found.

When you only want to write debug, what’s wrong with using the given delegateTask object directly?

Otherwise you could use Listener Type “expression” with a bit more control, but no big difference for me.
https://docs.camunda.org/manual/7.10/user-guide/process-engine/delegation-code/#task-listener