AnsweredAssumed Answered

Alfresco Activiti-App: showing attached process and task documents

Question asked by mikeblum on Jul 8, 2015
Latest reply on Jul 14, 2015 by mikeblum
Hi,

I'm attempting to programatically attach a file to an Activiti Process Instance. I've proved out that I can set the text of a form field but am not able to attach a document yet.

My first attempt was to add a byte array of the file to the properties ultimately being sent to the process before calling

FileInputStream fs;
      try {
          fs = new FileInputStream("test-doc.pdf");
          //attach it to the process at large
          //TODO: get the attachment mimetype
          workflowData.put("workflowdocument", IOUtils.toByteArray(fs));
          logger.info("Attaching file as workflowdocument to process");
      } catch (Exception e) {
         logger.error("Failed to attach mock file to process", e);
      }

ProcessInstance newInstance = runtimeService.startProcessInstanceById(processId, workflowData);


My second attempt was to attach the attachment using the TaskService after the task had been created:


logger.info("Started workflow " + newInstance.getId() + " with process: " + processId);
        FileInputStream fs;
      try {
         fs = new FileInputStream("test-doc.pdf");
         //attach it to the process at large
         //TODO: get the attachment mimetype
         Attachment attachment = taskService.createAttachment("application/pdf", null, newInstance.getId(), "workflowdocument", "test doc", fs);
      } catch (FileNotFoundException e) {
         logger.error("Failed to attach file to process: " +  newInstance.getId(), e);
      }


But neither show in the activiti-app when viewing that task. But they are successfully being attached when I cross-check with the Task Service.

I can't seem to embed my screenshots here so here's an imgur link:

http://imgur.com/a/NvFkB#RDqfi4S

What is the proper way for attaching a document (a content item I believe?) to have it show up in the activiti-app interface?

Thanks,
Mike

Outcomes