cancel
Showing results for 
Search instead for 
Did you mean: 

Get Tasks of given Workflow

chandra_shekher
Champ in-the-making
Champ in-the-making
Hi,

Any Body would suggest me how to get all Tasks name for given Particilar Process Definition in Alfresco using java script API..

I tried calling getTasks but it just gives me one task not all tasks..

for example in my workflow i have 3 tasks.

Start,
Assesment
And review..


so the function should returns all task in array…

your suggestion would be much appreciated..

/Chandra
2 REPLIES 2

jenniferh
Champ in-the-making
Champ in-the-making
Does anyone have an answer for this one? I'm facing the same problem. The documentation says getTasks "Returns all the task instances associated with this workflow path. " However, it only returns the currently active one. Please help!

mitpatoliya
Star Collaborator
Star Collaborator
In order to get all the tasks related to particular workflow you can use Workflow task query class.
WorkflowTaskQuery query = new WorkflowTaskQuery();
         query.setActive(null);
         query.setProcessId(wi.id);
         query.setTaskState(WorkflowTaskState.COMPLETED);
         query.setOrderBy(new WorkflowTaskQuery.OrderBy[] {
                  WorkflowTaskQuery.OrderBy.TaskCreated_Desc,
                  WorkflowTaskQuery.OrderBy.TaskActor_Asc });
         List<WorkflowTask> tasks = Repository.getServiceRegistry(context).
                  getWorkflowService().queryTasks(query);

NOTE: wi=workflow instance so wi.id=workflow id
This will return you the all the tasks of workflow which are completed.
then for getting tasks which are inprogress you need to again fire query with taskstate as INPROGRESS.