Proper way to change the name of an uploaded file document

Hi all, I want to change the name of an uploaded file document. The data view for a Specification object (that inherits from System.FileDocument) is nested inside the data view of the Order object. When saving the Order, I want to change the filename of the Specification file document to contain the order number and some other attributes. What is the proper way to do this? At the moment, I have added an action trigger button next to the upload control to trigger the upload. The microflow behind it changes the Name attribute of the Specification object (without committing it). However, I see some strange behavior where the filename sometime reverts to its original. Edit: The problem occurs in a customer application which runs on Mendix version 2.4.5. Any ideas? Thanks, Jonathan
5 answers

The FileDocument.Name attribute is set before uploading the image to the server. This is triggered by saving the object. Objects are saved when clicking the "Save" button or when clicking a microflow trigger. However, this save event and the actual uploading of the image run in parallel.

So, in your case there are two possible outcomes:

  1. Uploading the image is finished before the object is committed in the microflow. The name of the object will be the one you gave it in the microflow.
  2. The microflow is finished before the object is committed while uploading the file. Now the name you gave the object in the microflow will be overwritten by the name chosen when the file was being uploaded.

To defeat this race condition I would advise to change the name of the object in a before commit event. This will ensure that before actually committing the object into the database, the name is always changed to the name you would like it to have.


The FileDocument.Name attribute represents the actual name of an uploaded file (e.g., "notes.txt"). In 2.5-beta, this attribute is used to determine whether there is an actual uploaded file for a FileDocument object. If the name is not empty, an uploaded file is assumed to exist. This is the reason that we disabled writing to the Name attribute in 2.5-beta.

In the final 2.5 release we will add a boolean attribute named 'HasContents' to the FileDocument entity to represent whether an actual file exists. The Name attribute will be freely editable in that version.


See this thread


Ah, but the problem occurs in a customer application which runs on version 2.4.5 :-)

Any ideas why the Name attribute should get reset to its original value?


Has there been an update to this? Any new approaches?