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

b_schnarr
Champ in-the-making
Champ in-the-making
Ok, just for my understanding: With the new version 5.15, do I have a chance to realize my requirement? What does this exactly mean :"This fix will expose these attachments on all tasks of that process". Lets say I start a new process instance, am I able to attach a link to ALL tasks that are part of this process in a way that the attachment is shown in the activity explorer?

Thanks for your quick reply

frederikherema1
Star Contributor
Star Contributor
Yes, you will be able to attach an attachment to a task. All other tasks in that task's process (future and existing) will show that attachment in the Explorer UI as "related content". An explicit call to add an attachment ONLY to a process-instance is not yet included since this is inconsistent with the Java-API, which allows you to add attachments only though the taskService.

b_schnarr
Champ in-the-making
Champ in-the-making
Wow, that is great! So the steps would be:

1.) Start a process instance via rest (e.g. a process which has 3 user tasks)
2.) Attach the document link to ONE of those 3 tasks via REST
3.) All 3 tasks will show the related content in the UI
Am I right?

Could you give me a an estimation when the new version will be released?

Thanks for your reply!

frederikherema1
Star Contributor
Star Contributor
Yes, those 3 steps would become possible in the 5.15 release, scheduled for half of february (15th I think).

Just out of curiosity, are you actually using Activiti Explorer as a fronted for your users? It's initially intended to be used as a demo-app to get familiar with the API-calls and concepts Activiti offers…

b_schnarr
Champ in-the-making
Champ in-the-making
We are planning to extend the functionalities of an existing Enterprise Content Management Archive with document-routing services. Therefore, we want to start processes in the ECM-GUI and set parameters for the involved documents as links. For the interaction with the processes (document approval), we plan to use the activity explorer so we do not need to render forms etc in the ECM GUI; In addition, it would be overdosed to develop a separate GUI just for this case.

b_schnarr
Champ in-the-making
Champ in-the-making
I tried to attach one Document-Link to ONE task of a specific process via REST but the attached link is not shown in the activiti explorer even though the attachment is successfully added. The POST Request is:

http://10.120.40.24:8080/activiti-rest/service/runtime/tasks/2626/attachments with the body:

{
  "name":"test link",
  "description":"test",
  "type":"simpleType",
  "externalUrl":"https://www.google.de"
}

When I query all attachment of this task with rest with GET http://10.120.40.24:8080/activiti-rest/service/runtime/tasks/2626/attachments, I can see this attachment. But the activiti explorer only shows the comment on the right side, that the link was attached. The link itself is not shown.

When I attach a link in the activiti explorer, I can see this link in the explorer, but not in the rest query. Could it be that the links which are shown in the "related content" section are stored in another table? It seems that the attachments via REST are separated from the attachments created directly in the explorer.
Both web apps use the same database and all other data is consistent.

It would be great if someone could help me. Thank you very much


b_schnarr
Champ in-the-making
Champ in-the-making
I found the difference. When I add an attachment via activiti explorer, the TASK_ID is null and the PROC_INST_ID is set to the corresponsing process instance id in the table act_hi_attachment. When I add an attachment via REST, the TASK_ID is set and the PROC_INST_ID is null.
Look at this picture: https://www.dropbox.com/s/6vpoyxssoq90yxx/attachment_rest.png
I have added two attachments to the task with the task_id = 2667. The corresponding process_instance_id is 2662. The activiti explorer shows only those attachments, where the PROC_INST_ID_ is set. Wouldn´t it be better if both variables (task_id and PROC_INST_ID_) were set no matter if the attachment is added via rest or via the activiti explorer?

Should I open an issue in the activiti explorer section?

Would be great if this could be fixed. I hope that I can contribute with this post.

Thank you very much
Ben

trademak
Star Contributor
Star Contributor
Hi Ben,

We make a difference between process instance attachments and task attachments. But the Activiti Explorer could be enriched by also showing the task attachments. We still need to add a REST service to add attachments to a process instance as well.

Best regards,

b_schnarr
Champ in-the-making
Champ in-the-making
Hi Tijs,

thank you for your quick answer. Will this fix : https://github.com/Activiti/Activiti/commit/57034fa44bfbaefdd2449d70cbe4da668659e687
solve my problem? Because Frederik said that with this fix, all tasks of a certain process will show the corresponding attachments in the activiti explorer

Best regards and thanks
Ben

trademak
Star Contributor
Star Contributor
Hi Ben,

Yes that should solve your problem.

Best regards,