The JavaScript API has no "task list for user X" method in one call; combine the search API (task list for a user) with the task objects, or query the current user's tasks:
// server-side script (any 8.5.x / BAW): tasks of a user through the search REST API called with BPMRESTRequest
var req = new BPMRESTRequest();
req.method = "PUT"; req.resource = "/search/query";
req.parameters = { "organization": "byTask", "run": "true", "filterByCurrentUser": "false", "size": "500",
"condition": "taskStatus|Received", "condition": "assignedToUser|" + tw.local.userName }; // several conditions: pass as an array in newer releases
var res = tw.system.invokeREST(req);
var rows = JSON.parse(res.content).data.data; // taskId, taskSubject, taskDueDate, instanceId, ...
tw.local.tasks = new tw.object.listOf.TaskInfo();
for (var i = 0; i < rows.length; i++) {
var t = tw.system.findTaskByID(rows[i].taskId); // TWTask: subject, status, assignedTo, dueDate, processInstance, priority
var info = new tw.object.TaskInfo(); info.id = t.id; info.subject = t.subject; info.due = t.dueDate; info.instance = t.processInstance.id;
tw.local.tasks.insertIntoList(tw.local.tasks.listLength, info);
}
// current user only, pure JS API (no REST): tw.system.user is the caller; the task list of the caller is not exposed either -
// the Process Portal uses the search / task list REST resources; use them.Client side (a coach for the logged-in user) it is simpler: the search query with filterByCurrentUser=true (question 756). On BAW 21+ the Process REST v2 GET /bpm/user-tasks?states=ready,claimed returns the caller's tasks (administrators can filter other users' tasks with the model / instance filters) - the clean API going forward.
References