05-15-2017 02:25 AM
How to get Attachment in alfresco?
I did something like this.
public void notify(DelegateTask delegateTask) {
List <Attachment> at = new ArrayList<Attachment>();
String processInstanceId = delegateTask.getProcessInstanceId();
at = delegateTask.getExecution().getEngineServices().getTaskService().getProcessInstanceAttachments(processInstanceId);
}
However it didn't work
05-15-2017 12:26 PM
Seems this is a duplicate of :
java - Alfresco Activiti - How get attachment id in alfresco activiti? - Stack Overflow
If you are using Activiti Enterprise you will need to use the relatedContentService.
Details of how to use this service can be found in the following forum post:
How do you access an uploaded file in a downstream service task?
It does appear you participated in this post, as far as I can tell the answer to your question can be found in the code snippet below:
public void execute(DelegateExecution execution) {
try {
String fileVariableName = "myfile"; // Id of 'upload file field' from form in previous User Task
Class<?> theClass = Class.forName("com.activiti.conf.ApplicationConfiguration");
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(theClass);
RelatedContentService relatedContentService = applicationContext.getBean(RelatedContentService.class);
List<RelatedContent> contentList = relatedContentService.getFieldContentForProcessInstance(
execution.getProcessInstanceId(), fileVariableName, 1, 0).getContent();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
Cheers,
Greg
Explore our Alfresco products with the links below. Use labels to filter content by product module.