How can I get all tasks assigned to an user: waiting tasks but not tasks completed in the workflow
Hi, I want to know how can I do this: I have a workflow running for each a of my nuxeo documents, this workflow have a WorkflowVariables: transcriber. How can I get all transcribers from workflows of my documents?
Or more easy: How can I get all tasks assigned to an user? open tasks by this user, waiting tasks by this user to be run but not tasks completed
1 votes
3 answers
2882 views
I am not able to access TaskService from my custom java code. What maven dependency I need to include in my core project ? org.nuxeo.ecm.platform.task package is not found.
You can try something like this:
protected CoreSession session = null;
protected List<Task> getAllTasks(NuxeoPrincipal principal) {
ArrayList<Task> userTasks = new ArrayList<Task>();
if (session != null) {
try {
List<String> actors = TaskActorsHelper.getTaskActors(principal);
TaskService taskService = Framework.getService(TaskService.class);
List<Task> tasks = taskService.getCurrentTaskInstances(actors, session);
if (tasks != null) {
for (Task task : tasks) {
try {
if (task.hasEnded() || task.isCancelled()) {
continue;
}
DocumentModel doc = taskService.getTargetDocumentModel(task, session);
if (doc != null) {
if (LifeCycleConstants.DELETED_STATE.equals(doc.getCurrentLifeCycleState())) {
continue;
} else {
userTasks.add(task);
}
}
} catch (Exception e) {
//exception handler
}
}
}
} catch (Exception e) {
//exception handler
}
}
return userTasks;
}
Hi, thanks for your answer, but the "taskService.getCurrent TaskInstances(actors, session);" method only gets active tasks and not waiting tasks or ended tasks.
05/14/2013