Delete attachment - workaround?

I have a list of messages on the page, users can create new messages by typing text in the text area below and click “send” button. How it works: I pass the non-persistable entity “ScreenLogic” to the page, it has some attributes for conditional visibility and a string attribute “MessageText” where the user enters text. When he clicks “send”, a microflow is taking the value from the “MessageText” attribute, and create a new object of the Message entity with this text. After that I reset the MessageText value to empty, so we could use it for the next message.   The challenge is that now I need to implement the file attachment feature the same way. I almost did it but got blocked by the strange fact that we can’t delete the attachment from the file manager widget. What I tried: Screen logic entity and Message entity now have generalization from the System.FileDocument entity. I use the file manager widget to add attachments to the ScreenLogic object. When I click “Send” I call a microflow, and I use community commons action to duplicate attachment from the ScrenLogic entity to the new Message entity. It works perfectly, but the problem is that after the new message is created, I can’t reset the file manager widget, and it still keeps the file I selected. So if I will submit a new message, even if I didn’t select any attachment, the attachment from the previous message will be attached automatically.  So I can’t delete the attachment from there (correct me if I’m wrong), and I can’t delete the whole ScreenLogic object, because it is used for many other things on the page including conditional visibility.  Please let me know if there is a way to reset/remove the attachment form the file manager widget, or is there any good workaround you would recommend?
1 answers

Please check if the below approach works for you:

- Message can be a different entity and associated with FileDocument

- When you want to reset, you can clone the Message without associations

So FileDocument does not gets re-created

Or, you must develop a logic that determines whether the object is duplicated and not edited (like isNew() in mendix)

- if yes, when loading the screen you must delete the document, which in my opinion is a long way for the solution you need