02-22-2018 07:39 PM
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());
02-23-2018 11:25 AM
Also, try wiring com.activiti.service.runtime.SubmittedFormService and use submittedFormService .getTaskSubmittedForm(taskId) for task complete events
02-23-2018 04:52 AM
APS uses a custom form service. If you designed and deployed the process in an APS app you should use AlfrescoTaskFormService.getTaskForm(taskId) instead.
02-25-2018 05:54 PM
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)
...
02-23-2018 11:25 AM
Also, try wiring com.activiti.service.runtime.SubmittedFormService and use submittedFormService .getTaskSubmittedForm(taskId) for task complete events
02-25-2018 06:25 PM
Thanks. This works great for TASK_COMPLETED events, but I'm still having trouble fetching task forms on TASK_CREATED events.
02-26-2018 05:16 AM
Seems that the event is triggered before the form is created. If assignee is set on the task you can try TASK_ASSIGNED event.
02-26-2018 11:50 AM
Unfortunately, I get the exact same error on TASK_ASSIGNED events. Any other suggestions?
02-26-2018 05:21 PM
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());
02-26-2018 06:59 PM
This worked on TASK_ASSIGNED events. I simply passed in task.getFormKey() to formStoreService.getForm. Thanks!
02-26-2018 07:52 PM
I'm glad that helped. Btw, that should work for any task event, it will provide the form regardless of the task state.
Explore our Alfresco products with the links below. Use labels to filter content by product module.