cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving task variables in a task query

aalaa
Champ in-the-making
Champ in-the-making
I do the following rest call to get a list of tasks :query/tasks
The variables attribute in the json response is always empty !
Why is that ?
Note :runtime/tasks/{taskId}/variables/{variableName}?scope={scope}  , this call works fine and the variable is retrieved
1 REPLY 1

vasile_dirla
Star Contributor
Star Contributor
Hi, could you provide some more details about the query/tasks call you do ?

(maybe a simple unit test which will show the behaviour.)

Considering the code in TaskQueryImpl

<code>
public List<Task> executeList(CommandContext commandContext, Page page) {
    ensureVariablesInitialized();
    checkQueryOk();
    List<Task> tasks = null;
    if (includeTaskLocalVariables || includeProcessVariables) {
      tasks = commandContext
          .getTaskEntityManager()
          .findTasksAndVariablesByQueryCriteria(this);
    } else {
      tasks = commandContext
          .getTaskEntityManager()
          .findTasksByQueryCriteria(this);
    }
   
    if (tasks != null) {
      for (Task task : tasks) {
        localize(task);
      }
    }
   
    return tasks;
  }
</code>

you should provide the  at least one of these 2 attributes with "true" value in the request. (which by default are false)
<code>
  private Boolean includeTaskLocalVariables;
  private Boolean includeProcessVariables;
</code>


see: TaskQueryResource.java
<code>
@RequestMapping(value="/query/tasks", method = RequestMethod.POST, produces="application/json")
  public DataResponse getQueryResult(@RequestBody TaskQueryRequest request,
      @RequestParam Map<String, String> requestParams, HttpServletRequest httpRequest) {
   
    return getTasksFromQueryRequest(request, requestParams);
  }
</code>