Current ask coming as null

From one of the Delegate class we’re initiating one more process and when trying to get the Active task, it’s coming as null. Pasted the code below, kindly help me on this as I am stuck here for quite sometimes. Thanks in advance.

ProcessInstance processInstance = runtimeService.startProcessInstanceByKeyAndTenantId(
“defKey”, “businessKey”, variables,
Task currentTask = taskService.createTaskQuery().processInstanceId(processInstance.getId())
.active().singleResult(); // currentTask coming as null

Hi venkata. we had different use cases, the following code snippet might be helpful. In our scenario, we needed to retrieve all the activities and then filter them based on time. Here’s the code snippet:

List<HistoricActivityInstance> activityInstances = processEngine.getHistoryService()

Set<String> completedActivityInstances = new HashSet<>();
Set<String> currentElements = new HashSet<>();

if (CollectionUtils.isNotEmpty(activityInstances)) {
    for (HistoricActivityInstance activityInstance : activityInstances) {
        if (activityInstance.getEndTime() != null) {
        } else {

 String currentId = currNode.get(0).toString();
 HistoricActivityInstance hinst = getCompleteTaskDetails(currentId, processInstanceId);

    public HistoricActivityInstance getCompleteTaskDetails(String taskId, String instanceId) {

        HistoryService historyService = processEngine.getHistoryService();
        List<HistoricActivityInstance> tasklist = historyService.createHistoricActivityInstanceQuery().activityId(taskId.replace("\"", "")).processInstanceId(instanceId).list();

        for (HistoricActivityInstance task : tasklist) {
            if (task.getEndTime() == null) {
                return task;

        return null;


Just go through activities it will give you some idea .