How to delete a file in a System.FileDocument?

3
Hi, We use an entity that inherits from System.FileDocument. The attached file is considered optional, so how do I remove the file from the System.FileDocument (either with Java or with a Microflow)? In the past I got the file in java and did a delete(), and set HasContents to false. Now this getting of the file is a deprecated function, so what is the alternative? Kind regards, Bart
asked
3 answers
2

This is currently not possible, I suggest filing a feature request.

answered
2

The feature request is still pending,

So for anybody that like to delete the file from the system, but keep the object; there is a work around with a java action.

public Boolean executeAction() throws Exception     {
        this.FileDocumentParameter1 = __FileDocumentParameter1 == null ? null : system.proxies.FileDocument.initialize(getContext(), __FileDocumentParameter1);

        // BEGIN USER CODE
        Core.storeFileDocumentContent(this.getContext(), this.__FileDocumentParameter1 , new ByteArrayInputStream(new byte[0]));
        this.FileDocumentParameter1.setHasContents(false);
        this.FileDocumentParameter1.commit();
        return true;
        // END USER CODE
    }
answered
-2

You can make an association from your entity A, to another entity B - which derives from System.File. Create B optionally, on click of "Upload button".

Let's say you have "CustomerComplaint" as your entity which may/ may not have file attachments. Complaint object can have one:many relation with ComplaintFiles object(s). ComplaintFile is created only when you click something like an upload button on a form.

answered