How can we clean up a file attached to a record?

  • 1
  • Question
  • Updated 4 years ago
  • Doesn't Need an Answer
We have a table of documents with document types, programs and a lot of other details, and then a reference to the Skuid File so that you can use the upload in the table and click on the name to open the file when one is added. 

However, if the user deletes the row, the related attachment is not removed along with the deletion.   So we could end up with a lot of un-attached files stored in the instance consuming our storage cap.  

I am obviously missing a step here..


Photo of Joseph Schreurs

Joseph Schreurs

  • 402 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Joseph Schreurs

Joseph Schreurs

  • 402 Points 250 badge 2x thumb
Ok so my work around that seems to function ok, my only question is if the Attachment object is being cleaned up automatically now or not.

1) Create a new Model "TheFile" with a filterable condition.  This condition, named skuid__AttachmentId__c can be modified by filters, but is off by default.

2) Create a new row action on your documents that run multiple actions
       <action type="markRowsForDeletion" model="AllDocuments"/>       <action type="setCondition" model="TheFile" condition="skuid__AttachmentId__c" value=       "{{Document__r.skuid__AttachmentId__c}}"/>
       <action type="requeryModel" model="TheFile" behavior="standard"/>
       <action type="markRowsForDeletion" model="TheFile"/>

3) Create a Page Title that renders only with TheFile model has unsaved changes and add a confirm you really want to delete these files?

4) Save your documents model and the file model


Am I missing anything?