cancel
Showing results for 
Search instead for 
Did you mean: 

Searching tasks by workflow initiator

alhol
Champ in-the-making
Champ in-the-making
Hello!
Here is a problem:
We've got a working code from java-backed web-script task-instances.get:

            // a workflow instance id was provided so query for tasks
            WorkflowTaskQuery taskQuery = new WorkflowTaskQuery();
            taskQuery.setActive(null);
            taskQuery.setProcessId(workflowInstanceId);
            taskQuery.setTaskState(state);
            taskQuery.setOrderBy(new OrderBy[]{OrderBy.TaskDue_Asc});
           
            if (authority != null)
            {
                taskQuery.setActorId(authority);
            }
           
            allTasks = workflowService.queryTasks(taskQuery);


Then we've removed line

            taskQuery.setProcessId(workflowInstanceId);

and got as a result, allTasks list contains all active tasks "belong" to all existing workflows in a system assigned to given authority. That is exactly what we need.

But there is another challenge: we need to retrieve all active tasks which belong to workflows <em>initiated</em> by given authority. The purpose is to create a page similar to /my-tasks where user can see all workflows he initiated and their current status, i.e. current task.

Can someone give advice how to do it? Simple brute-force search seems to be very slow. Thanks in advance.
2 REPLIES 2

mitpatoliya
Star Collaborator
Star Collaborator
I think you can use the My completed Task Dashlet.
Is there any particular difference between that and one you are trying to create?
well still if you have any such requirement you can add this line

//currentuser is user name of currently logged in user
taskQuery.setActorId(currentuser);

alhol
Champ in-the-making
Champ in-the-making
Thank you, I've already used this code, as you can see in my post, but this is not what I need. Apparently developers meant assignee as an "actor" in setActorId() method, so this line makes query to search task by its assignee (or owner). What I need, again, to search by workflow initiator.

If you talking about this dashlet: https://addons.alfresco.com/addons/site-task-manager, as I can see it differs from original not so much.