I'm using Alfresco Process Services 1.7
I've implemented a RuntimeEventListener for process lifecycle events and publish them out to a Kafka stream. It's working, but I was unable to fetch task's task_form on TASK_CREATED and/or TASK_COMPLETED events. I figured I'd be able to retrieve the task form with the following code:
EngineServices engineServices = event.getEngineServices();
FormService formService = engineServices.getFormService();
Task task = (Task) ((ActivitiEntityEventImpl) event).getEntity();
Object renderedTaskForm = formService.getRenderedTaskForm(task.getId());
Solved! Go to Solution.
Also, try wiring com.activiti.service.runtime.SubmittedFormService and use submittedFormService .getTaskSubmittedForm(taskId) for task complete events
APS uses a custom form service. If you designed and deployed the process in an APS app you should use AlfrescoTaskFormService.getTaskForm(taskId) instead.
Also, try wiring com.activiti.service.runtime.SubmittedFormService and use submittedFormService .getTaskSubmittedForm(taskId) for task complete events
I'm running your code on TASK_CREATED events inside the onEvent method of my RuntimeEventListener implementation. I successfully get the taskId, but I always get a similar error.
Task task = (Task) ((ActivitiEntityEvent) event).getEntity();
String taskId = task.getId(); // returns 192507
FormDefinitionRepresentation taskForm = alfrescoTaskFormService.getTaskForm(taskId);
05:44:43,068 [http-nio-8080-exec-10] WARN org.activiti.engine.delegate.event.impl.ActivitiEventSupport - Exception while executing event-listener, which was ignored
com.activiti.service.exception.NotFoundException: No task with id 192507 exists
at com.activiti.service.runtime.PermissionService.validateReadPermissionOnTask(PermissionService.java:95)
at com.activiti.service.runtime.AlfrescoTaskFormService.getTaskForm(AlfrescoTaskFormService.java:131)
at com.activiti.extension.bean.EagleEventListener.publishEvent(EagleEventListener.java:174)
at com.activiti.extension.bean.EagleEventListener.onEvent(EagleEventListener.java:350)
...
Thanks. This works great for TASK_COMPLETED events, but I'm still having trouble fetching task forms on TASK_CREATED events.
Seems that the event is triggered before the form is created. If assignee is set on the task you can try TASK_ASSIGNED event.
Unfortunately, I get the exact same error on TASK_ASSIGNED events. Any other suggestions?
From the log trace you provided it seems to be a permissions issue. It can't find the history task because it's hasn't been created yet. You can get the form directly using the FormStoreService
formStoreService.getForm(delegateTask.getFormKey());
This worked on TASK_ASSIGNED events. I simply passed in task.getFormKey() to formStoreService.getForm. Thanks!
I'm glad that helped. Btw, that should work for any task event, it will provide the form regardless of the task state.
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.