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
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
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.