Look like you stumbled upon one of those wtf moments.
As you have discovered Mendix handles file objects slightly differently compared to all other objects. For example, when uploading a file the file object is committed at the moment the microflow is triggered. This is how the platform works and I am sure there is some reason why it works like that.
What can you do?
Here is an idea: add a boolean flag to the file document entity. This flag is only set for the user-facing upload form. In the event handler if the flag is set skip the handling of the event. Explicitly commit the file document object again when the user clicks save (after some validation).
Hope this helps,
Hi Andrej, indeed, one of those moments!
I can’t see any place in the entity event handler to tell it skip calling the microflow based on a flag. That is unless you mean to skip the handling within the microflow? The thing is, none of the FileDocument and my specialization entity attributes changed when a file is uploaded so there’s really no way to know when to set or clear the flag...that can only be done when saving the object.
I’ve already made it work by committing explicitly from a mf as you suggested and do some validation but I’m trying to avoid this...it means creating more mf’s and changing many buttons. Not lazy, just trying to keep it simple when I have tendency to make things complicated when they don’t have to be :)
Thanks again for the advice!