Hi All,I have a requirement, like one of the user task, say approve/reject task needs to be done automatically thorough Java API.I have written a code as shown below, to retrieve the list of tasks for a particular user and tried to approve programatically.
List<WorkflowTask> workflowTaskList = workflowService.getPooledTasks(serviceRegistry.getAuthenticationService().getCurrentUserName());
for(WorkflowTask wfTask : workflowTaskList){
try {
Map<QName, Serializable> wfProps = new HashMap<>();
//Approving the content
wfProps.put(HCCustomModel.QNAME_HC_REVIEW_OUTCOME, HCCustomModel.REVIEW_APPROVE); //Adding "Approve" workflow property
workflowService.updateTask(wfTask.getId(), wfProps, null, null);
wfProps = wfTask.getProperties();
for(QName key : wfProps.keySet()){
logger.info("Key : "+key+" , Value : "+wfProps.get(key));
}
workflowService.endTask(wfTask.getId(), null);
} catch (AlfrescoRuntimeException e) {
logger.error("An error occured while processing the task:"+wfTask.getId(), e);
}
}
But when I execute, the task always gets rejected(as "Reject" is the default action for the task), even though I update the task with "Approve" workflow property.Can any one point me out what I am doing wrong here.Or, the approval can't be done through Java API?Any guidance/suggestions would be greatly helpful to me.Thanks and Regards,Satheesh D