In Tasklist when saving attachments are deleted

I have a process where I have a user task in my Camunda Tasklist in which I have a file upload and some text fields.
I am adding some contents to the text fields and I upload a file and to work proceed with my work on it later on I am clicking on “save”.
However when I am clicking on “save” the attachment is gone. All text fields are stored correctly, but the attachment is always gone.

Is there a way to save the attachment or is this not possible?

Hello @MarvinKern ,

the lifecycle of an embedded form is described here:

However, do you use the directive for file uploads?

I hope this helps

Jonathan

1 Like

Hello @jonathan.lukas ,
Thanks a lot for your answer.
My code for the file upload looks the following:

<div>
      <label for="logo_attachment">Logo Dateiupload</label>
      <input type="file"
             id="logo_attachment"
             cam-variable-type="File"
             cam-variable-name="logo_attachment"
             cam-max-filesize="10000000"
             ng-model="logo_attachment"/>
</div>

Are the variables that are of the cam-variable-type “File” not taken into account when the event ‘store’ is fired?

Thank you.

Hello @MarvinKern ,

this could be. In fact, some browsers do cache file upload data. However, you should be able to achieve this by adding event listener capabilities.

Jonathan

Hello @jonathan.lukas,

Thank you for your help so far.

So my idea so far is to use the store event:

<script cam-script type="text/form-script">
    camForm.on('store', function(evt) {
      // handle store
      // may prevent the store from being executed
      evt.storePrevented = true;
    });
  </script>

But then I dont know what to do in this event. Do you have a concrete example how to store an uploaded file manually to a camunda-variable in angularjs?
Thank you so much.

It would be nice to know what exactly happens when the submit button is clicked. Because at that point the uploaded file is stored finally to a camunda-variable. If I do the same when storing my problem should be solved.

Hello @MarvinKern ,

here is a list of all available event listeners:

From your snippet, I would assume you already found it.

I would now use 2 events: store and variables-restored.

The function in store could create an entry in the local storage which the function in variables-restored could load again.

To clean up afterwards, you could use submit-success and clear the stored variables which are not required any more.

I hope this helps

Jonathan

1 Like

Hi Marvin,

Sorry for re-opening this thread, but were you able to resolve this? Would you mind If I ask how you were able to persist the attachment when saving?

Thanks!