Attachment and ECM enterprise contents management

We have ECM running along with ERP system integration.
Camunda provide uploading function natively, but I am wondering how to forward attachment to ECM system and link with BPM process/task.

Any advice appreciated

1 Like

I’m also interested on this topic, mainly with Alfresco as the ECM system.

Please, let me know if you find anything about it.

I would love some more information on this as well. Although a DMS would suffice so far for my use case. Extending this to a ECM would be great asset for the solution I am trying to build though.

I already asked Camunda on twitter and they referred to this forum and that this is a common usecase. I sadly could not find more than this thread so far.

How does your ECM allow you to upload files/attachments?

Hey. This is a relevant and interesting topic for me, so lets give this a shot:

Two goals:

  1. Upload a File to the ECM (lets use Alfresco in this example)
  2. The file has related metadata about the task and process the file came from.

So Alfresco has the following:
http://docs.alfresco.com/5.0/references/RESTful-UploadUploadPost.html

If you were to POST to alfresco (using java delegate, Script task, or service task) the file that is uploaded as a attachment or process variable, you can pass the attachment as the file data.

You would want to use a Custom content type: Working With Custom Content Types in Alfresco | ECM Architect | Alfresco Developer Tutorials
or you can use the Description field as listed in Alfresco Docs - Repository Web Scripts Tutorials. The preference would be to use a custom content type.
In that content type you would have fields for Process ID, Task ID, Deployment ID, etc. (whatever data you wanted to transfer along). You would then generate/create a URL on the Alfresco/ECM side that links back to Camunda using the metadata you stored.

If you stored the metadata in the description field, I would recommend storing it as a JSON string. See this example for getting Process ID, Task ID, etc metadata:

@choibc @douglascrp @fherpertz see the following for a example of how you could using scripting in your form to post your file. Loading previous data in process start form - #2 by StephenOTT. This example using GET, but basics are there.

Personally i have preference for POSTing using Java Delegate / Script task / service task, but there are good use cases for posting from the form as well.

2 Likes

@choibc @douglascrp @fherpertz

Okay i put together a little example.

My usual preference is to use JavaScript for scripting, but Groovy has cleaner syntax for converting Bytes to Base64.

So here is a simple example that allows you to set a document name and upload a file as part of the Start Event. (You can make it a User Task as well if you like).

Then there is a script task (using JS) to get a bunch of “metadata” about process instance.

Then there is a Service Task that combines the File Name, Metadata, and upload file into a POST to a API. For this example i created a sample api end point with Deployd and created a resource (/ecm) with 3 fields: fileData, fileName, processInfo.

I used execution.getVariableTyped("Document").getValue() to get the file as a Bytes object, and then built a groovy object, and then converted the object to JSON.

import groovy.json.JsonOutput

def doc = execution.getVariableTyped("Document").getValue()

def obj = new LinkedHashMap();
obj.fileData = doc.bytes.encodeBase64().toString()
obj.fileName = execution.getVariable("DocumentName")
obj.processInfo = execution.getVariable("ProcessMetadata")

JsonOutput.toJson(obj)

I wanted to do all of this as part of the “payload” so that we were not storing any camunda process variables of the files as strings (which have a size limit).

@camunda is there a way through the Java API / execution object to get a file as Base64/binary as with the REST API? Could not find the corresponding methods in the javaDocs.

Example files (change .xml file to .html):
fileUpload.xml (408 Bytes)

EcmUploadExample.bpmn (6.9 KB)

2 Likes

I am running into the same kind of issue. Have you ever found a way to post a File back out to a rest API? Thanks.