File Variable Not Available After Form Upload


#1

Hi, I wonder if anyone might be able to assist with the following issue I am having with file uploads.

Currently our bpmn model have an embedded form which allows file uploading. On the form we make use of the angular camForm.on(‘submit’) method to upload the files like below

                  camForm.variableManager.createVariable({      
  						name: documentData,   
						type: 'Bytes',
						value: file.data,
                        isDirty: true
					});

After the embedded form we sent the processInstanceId and the variable name to another service which downloads this variable via the camunda REST API /process-instance/processInstanceId/variables/variableName/data This is working fine until we moved this process to within a CMMN case, what I then realised is that the variable would be located within the case execution REST endpoint at /case-execution/caseExecutionId/variables/variableName/data after switching to this it work until we remove the human task between the embedded form and the file download service. When the file download service calls this endpoint the REST API returns a 404.

I can confirm that the file has been uploaded but at the point when the file download service is executed it seems either the variable is not persisted at that point or the file upload has not yet completed.

If anyone could perhaps shed some light on this. Does the camForm.variableManager.createVariable complete and persist the file data before the process model continues or could it still be busy when the next tasks in the BPMN is called? Then would there be another simpler way to send a reference of the file variable to the file download service to be downloaded? I am thinking in rather using the variable instance URL but I am not entirely sure how to retrieve the URL.

Any help would be appreciated.


#2

Hi @some-camunda-user,

could please give more details how you connected the CMMN part with the service task?

Cheers, Ingo


#3

@Ingo_Richtsmeier thank you for the response. I managed to resolve the issue yesterday and haven’t updated this post yet.

It turns out that when the user task was in place it forced a Wait State as described in “Transactions In Processes” article (https://docs.camunda.org/manual/7.5/user-guide/process-engine/transactions-in-processes/). After we removed the user tasks there was no Wait State and the variables was not yet committed explaining why we got a 404 when we did http REST request. By adding the file download service as “async before” allowed the variables to be persisted prior to calling the file download service and has resolved the issue.


#4

Hi @some-camunda-user,

thank you for posting the solution.