cancel
Showing results for 
Search instead for 
Did you mean: 

Task State to filter WorkflowInstanceQuery

dave984
Champ in-the-making
Champ in-the-making
In my activity bmpn i have some states such as "Start Process", "Review", "Second Review" and so on…
When i start the Workflow in Share i can navigate it through all states.
Now, how can i retrieve the current state in my custom webscript?
Here some code:

WorkflowInstanceQuery workflowInstanceQuery = new WorkflowInstanceQuery();
  
// get filter param values
Map<QName, Object> filters = new HashMap<QName, Object>(9);
if (req.getParameter(PARAM_TASK_STATE) != null){
     filters.put(??????????, req.getParameter(PARAM_TASK_STATE));
}
workflowInstanceQuery.setCustomProps(filters);
workflows.addAll(workflowService.getWorkflows(workflowInstanceQuery));


For example for the Review and Approve basic Alfresco's workflow the state i'm trying to retrieve are "Start Review", "In Review", "Approved", "Rejected"…
Someone have an idea?!
3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator
Param values added to customProps map will be parse as activiti global variable.
So if you had added PARAM_TASK_STATE into  process instances global variable in you workflow,you can query using customProps

vangnd1
Champ in-the-making
Champ in-the-making
Hi Dave984 , I have same problem with you , Do you solved it ?

Can you help me ! please give me your solution , this is my email fsoft.vangnd1@gmail.com

Many Thank Smiley Happy

vangnd1
Champ in-the-making
Champ in-the-making
I have received message from Kaynezhang !

This is his solution , and my problem has resolve .

The brief process is like below:
1.Whenever state changing task such as "Start Review", "In Review", "Approved", "Rejected" is executed,persiste process variables (for example PROCESS_STATE) into database.

execution.setVariable("PROCESS_STATE",state);


2.Get workflow instances according to the state(global variables)

WorkflowInstanceQuery workflowInstanceQuery = new WorkflowInstanceQuery();

Map<QName, Object> customProps = new HashMap<QName, Object>(9);

workflowInstanceQuery.setCustomProps(customProps);

workflowService.getWorkflows(workflowInstanceQuery);