How to avoid duplicate files uploaded to Mendix using System.FileDocument

0
Hi, I am using   MyDocument → ( System.FileDocument)  entity to upload the XML file into Mendix system. During upload , I am selecting name and  Browse / path for the file and clicking Save button to save the document into  System.FileDocument.   If the same file is being uploaded one more time then system should not upload the document rather it would say file is already uploaded etc.  For this requirement , I have added a MicroFlow → Onclick of Save button to check whether System.FileDocument table has the file name equals to MyDocument file name ( The one going to be uploaded) and based on that deciding if this file can be uploaded or not. But While entering into my MicroFlow ( On click save)  itself the System.FileDocument table has the new file already uploaded. Does any one know how to avoid duplicate file is being uploaded. Appreciate your inputs / help on this.
asked
1 answers
1

Hi there,

It is important to note that when you select a file to upload, Mendix uses the name of the actual document that you uploaded, even if you type something different into the Name field – it will override this.  This happens before committing.

EDIT: For reference, I have added what the Microflow would roughly look like: https://modelshare.mendix.com/models/168d62db-84c3-4c63-a1b1-3bb83a30629b/save-file 

EDIT:  Also make sure to exclude your new document in the XPATH for your “table” retrieve like this:

 

This might be why you are seeing this.  So in this case ONE of many possible solutions could be to Inherit from the System.FileDocument entity using Generalization:

And then you can use your own attribute to manage the uniqueness of the File names

I hope this helps!

answered