AnsweredAssumed Answered

Explorer fails on 'standalone' tasks (without process)

Question asked by jammann on Aug 5, 2011
Latest reply on Aug 10, 2011 by jbarrez
Hi all

I tried to use the task service of Activiti 5.6 "on its own", without associated processes. We are investigating this because we have some requirements for simple task management, which does not really require a full process model.
So I tried something like

TaskService taskService = pe.getTaskService();

// Create and save task
Task task = taskService.newTask();
This seems to work, I can query the task and handle it with the API. It is also correctly inserted into the database. But - as was to be expected - the task instance lacks a process_inst_id and execution_id.
When I tried to look at the tasks I created with Activiti Explorer, it was showing that there are some tasks, but was unable to show the details. The logs showed

18:11:31,343  ERROR [freemarker.runtime]
Expression jsonUtils.encodeJSONString(x) is undefined on line 1, column 15 in org/activiti/rest/api/task/task.lib.ftl.
The problematic instruction:
==> ${task.executionId} escaped ${jsonUtils.encodeJSONString(task.executionId)} [on line 19, column 18 in org/activiti/rest/api/task/task.lib.ftl]
in user-directive printTask [on line 7, column 5 in org/activiti/rest/api/task/task.lib.ftl]
in user-directive taskLib.printTaskList [on line 4, column 11 in org/activiti/rest/api/task/tasks.get.json.ftl]
After some googling, I found that this is probably due to some value being null. Sure enough, the template contains

  "assignee": <#if task.assignee??>"${task.assignee}"<#else>null</#if>,
  "executionId": ${task.executionId},
  "processInstanceId": <#if task.processInstanceId??>"${task.processInstanceId}"<#else>null</#if>,
Since the executionId is null, this fails. Making it similar to the other checks fixed the problem.
Now I'm not sure if that is just a little bug - or if the Task Service was never meant to be used like this?? The API would really be sufficient for what we need, and I don't see the point in using a different task engine.

Regards, Joe