Ng-if troubles

Hello,

I have a problem while using ng-if statement inside an embedded form.
I have such a construction:

<input ng-if="requestDocument2Available" cam-variable-name="requestDocument2" cam-variable-type="File"
    cam-max-filesize="10000000" type="file" class="form-control"/>

By using nf-if it seems that even if the boolean operation result is true, the variable requestDocument2 is not created inside the camForm.variableManager.

Therefore if the file is selected it is never attached for download even if the current step is completed and form submits successfully.

Is there a way to update the variableManager with this variable to get this file uploaded for download?

I hope I explained it correctly. I would gladly give more info if needed.

Thanks and kind regards,
Deniss

Hi,

Would really appreciated some advise if possible :slight_smile:

Thanks and Kind regards,
Deniss

You should use ng-show which does not create a new child scope.
Camunda directives don’t work well with child scopes.

If you have to use ng-if then you have to bind all variables to the variableManager manually. You can find the where and how in the documentation;

https://docs.camunda.org/manual/7.4/reference/embedded-forms/javascript/lifecycle/

Hello,

Thanks. I don’t think I can use ng-show, since the variable directives are always initialised in this case.

I have two upload fields. Upload1 and Upload2.

  1. User selects only one file.
  2. variableManager.destroyVariable deletes the empty Upload2 upon submit, since it is empty.
  3. Second form checks if there is Upload2 or not;
  4. By using ng-if it is decided if will show either download link (if Upload2 was not empty) or a new upload field (if Upload2 was empty) by using the same cam-variable-name Upload2.

The problem is that by using ng-if the cam-variable-type and cam-variable-name are never initialized… currently I do not have a solution for this issue.

Kind regards,
Deniss

If you run Camunda 7.4 you will run into troubles anyway… There is a bug that crashes the form when you use a camunda file directive that is not defined. You then have to create a variable with name Upload2 and value null.

My suggestion; keep form1 as it is and use REST-services in form2 instead of the camunda directives.
This way you will go around the empty file bug + you can use ng-if as you do not use the directives.

GET variable (binary)
https://docs.camunda.org/manual/7.4/reference/rest/task/variables/get-task-variable-binary/

or
GET local variable (binary)
https://docs.camunda.org/manual/7.4/reference/rest/task/local-variables/get-local-task-variable-binary/

1 Like

Hi,

That’s a great idea, thanks! But what about file upload in form2?

Kind regards,
Deniss

Then you use the POST method.

Post Task Variable (Binary)

Also discussed in the following topic;

2 Likes

Hello,

Thanks! This works perfectly! Now I think my troubles are solved. Thanks once again! I will update the post with my solution later.

Kind regards,
Deniss