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:
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.
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?