Error deleting FileDocument descendant when nothing was uploaded

I must be missing something ;-) Object EntityWithOneDocument is associated with (FileDocument descendant) CISDocument When the user starts entering a new EntityWithOneDocument (microflow button) I do: create EntityWithOneDocument create (New)CISDocument set EntityWithOneDocument_CISDocument to NewCISDocument so that there is a CISDocument that we can have an Upload button for. The user is not required to upload a document. If he does not do that, in the save microflow, I do: Retrieve CISDocument by association $EntityWithOneDoc/EntityWithOneDoc_CISDocument Check CISDocument.HasContents if false, delete CISDocument (in an earlier attempt: if false, set EntityWithOneDocument_CISDocument=empty IIRC) Error: The association EntityWithOneDoc_CISDocument of object EntityWithOneDoc with data store id xx refers to a non-existing object CISDocument with data store id yy. What am I doing wrong?
1 answers

The error was in committing in the wrong place (too bad I did not mention those in my original question). The 'save' microflow ended with a commit, this had to be moved to right after the retrieve. (Has to do with the data still being in the client and not in the database. This stuff keeps confusing me).

Thanks to Matthieu for pointing this out.