Adding FileDocument automatically commits to database
Hello! I'm working on a project where users can create a project and include one or multiple documents. The project may only be committed to the database when the user either saves it as a draft version or submits the project as a whole. Although non of the buttons or microflows that are involved in uploading and linking the document commit anything, I always end up with the whole project being committed to the database anyway. I am able to select a file when clicking on “Browse”, but when I want to exit my pop-up screen by either cancelling or by refreshing in client and closing the page, it commits the file and the project. That's why I was wondering if it's even possible to attach a document (entity A) to another entity (entity B) without committing either one of them. Or is this normal when dealing with FileDocuments to not being able to keep them in your cache? Thanks in advance!
I also had a similar issue. If you are using the file uploader and select the path to your file, it will upload and commit the file on any other button click. There is no way to keep it in the cache.
A “very dirty” workaround would be to add a flag that is only set to true if the user clicks your custom save button, so that you are able to identify database records where the user did not save it. Now you can create a scheduled event that is looking for orphaned file objects and deletes them.
If there is a better solution, please let me know.
We use a tmp_attachment object. On save we duplicate this to the final destination. For duplication we use ‘Duplicate File Document’ java action from the Community Commons.
Another workaround, but still a little dangerous when having big files,is to convert the file to base6, and keep it in memory.
but even you make a workaround, there will be a problem with the other object associated with, it also will be commited!but even you make a workaround, there will be a problem with the other object associated with, it also will be commited!
You can also make a one to one with delete behavior?