02-04-2017 12:34 AM
Hi,
We are using Enterprise Activiti 1.5, I'm trying get the assignee details in the java code that's invoked from "ExecutionListener" of the User Task but not able to get it.
I'm able to get the assignee details in the java code using "TaskListener" of the User Task like below,
String assignee = delegateTask.getAssignee()
Is it possible to get the assignee details in "ExectionListener"? Please let me know.
Thanks!
02-06-2017 11:38 PM
Hi eramesh _ ,
Did you set the candidate users for the user task?
For example,
<userTask id="task" name="My Task" activiti:candidateUsers="${ldapService.findAllSales()}"/>
Then, if the assignee is within the candidate users, delegateTask.getAssignee() should return the Assignee correctly.
Thanks,
Thong Huynh
02-07-2017 12:52 AM
HI eramesh _ ,
Apologies, I didn't notice that you were specifically referring to ExecutionListener.
Did you try this?
public class MyExecutionListener implements ExecutionListener {
Logger logger = Logger.getLogger(MyExecutionListener.class);
public void notify(DelegateExecution execution) throws Exception {
// TODO Auto-generated method stub
logger.info("Execution, task assignee: " +
execution.getEngineServices()
.getTaskService().createTaskQuery()
.processInstanceId(execution.getProcessInstanceId()).singleResult().getAssignee());
}}
As an alternative, you can create TaskListener to handle more actions upon task events, here's an example
public class MyTaskCreateListener implements TaskListener {
Logger logger = Logger.getLogger(MyTaskCreateListener.class);
public void notify(DelegateTask delegateTask) {
// Custom logic goes here
logger.info("User task is created.");
logger.info("Listener executed.");
logger.info("Delegate Task assignee: " + delegateTask.getAssignee());
DelegateExecution execution = delegateTask.getExecution();
RuntimeService runtimeService = execution.getEngineServices().getRuntimeService();
runtimeService.signalEventReceived("EMAIL_SUPPORT_SIGNAL");
}
}
Thanks,
Thong Huynh
Explore our Alfresco products with the links below. Use labels to filter content by product module.