cancel
Showing results for 
Search instead for 
Did you mean: 

Attach document-link to process instances via new REST API

b_schnarr
Champ in-the-making
Champ in-the-making
Hello at all,

we want to upload attachments to user tasks AND process instances via REST API in a way that the users can see those attachments in the activiti explorer.

Especially, we want to attach links to documents, not the document itself. I know that you can attatch document links to both, user tasks AND process instances via Java API with the method

Attachment createAttachment(String attachmentType,
                          String taskId,
                          String processInstanceId,
                          String attachmentName,
                          String attachmentDescription,
                          String url)


With the new REST API (Activiti 5.14), you can create a new attachment on a task, containing a link to an external resource.
The Question is: Can you attach those links to process instances, too? (like the Java API can?)

We just can communicate with Activiti through REST. Therefore, we need a way to "store" document links in a global process variable so that the user can access those links via the activiti explorer.

I hope that somebody can help.
Thanks and best regards
Ben
24 REPLIES 24

trademak
Star Contributor
Star Contributor
But if you only want to add a link you could also just use a process variable for that.
You're right that adding attachment links is currently only available for tasks in the REST API. If you also need it on process instances, please create a JIRA issue and we'll add it to the REST API.

Best regards,

b_schnarr
Champ in-the-making
Champ in-the-making
Thank you for your quick reply. If I use a process variable to attach the link, is this link visible in the activiti axplorer?

best regards,
Ben

frederikherema1
Star Contributor
Star Contributor
I comitted a fix for this.. The process-instance ID was not populated, when uploaded through REST…

Thanks for your reply. Does that mean that it is now possible to attach a link to a process instance correctly via REST API? How can we use this fix?

frederikherema1
Star Contributor
Star Contributor
The fix involves populating the process-instance id when a task-attachment is added trough REST. Adding attachments without a task is currently not possible. Add attachments trough tasks that are part of the process, and they will appear in the explorer the way they should….

Do we have to use another activiti commit for that? Will this fix be included in the next release?

jbarrez
Star Contributor
Star Contributor
Frederik has committed a patch for it on https://github.com/Activiti/Activiti.

You can either build a snapshot version yourself (mvn clean install) or wait for the next official release.

b_schnarr
Champ in-the-making
Champ in-the-making
We need to implement a document-centric process (like a document-approval process). Therefore, each task in this process should have the same link to the document attached (and it must be visible in the activity explorer). In addition, we want to trigger the process via REST. Is this possible via REST? I know how to start a process via rest, but I have no idea how to attach the link to ALL tasks in the process in a way that the link is shown in the activity explorer when I start a process instance?

frederikherema1
Star Contributor
Star Contributor
Currently, we only support adding attachments to a task. However, I've fixed an issue with that resource, so that the process-instance ID is also populated (will be available in 5.15, 5.14 won't show the attachments process-instance wide):

https://github.com/Activiti/Activiti/commit/57034fa44bfbaefdd2449d70cbe4da668659e687

This fix will expose these attachments on all tasks of that process (in case the task is part of a process).  The REST-resource I was referring to is posted below and supports both URL-attachment (JSON-body) and file-attachment (multipart-body).


POST runtime/tasks/{taskId}/attachments