How to delete object without attachments (check attachment size)?

0
A user can create objects of an entity “Message”, and add file attachments to it. In some cases I need to delete e,pty messages with no text and no attachments. How can I check if there are any attachments to the message? Can I somehow check if the attachment size is greater than 0?
asked
2 answers
1

Have a look in the Community Commons module in the Marketplace. In the Files folder, there is a Java Action called getFileSize that should do what you need.

Hope this helps.

answered
1

If your Message entity inherits System.FileDocument, then you can use the FileDocument.HasContents boolean to find the document entities. If your Message entity has a relationship to another entity that inherits System.FileDocument, then you can either check the association for empty or for the associated object to have FileDocument.HasContents false. Typically, I check for the boolean over checking the association because the File widget commits the object more that you’d think.

answered