Today will  see how attachment recovery  feature works  and some technical details behind this feature which was released in PU 29.

 This feature provides recycle bin for record attachments  where in user can recover  deleted documents using the deleted attachment form with in configured period of time in Document management parameter screen.

Once you enable this feature from feature management , you have to enable deferred deletion  using above form located at Organization Administration > Document management > Document management Parameters. The actual field DeferredDeletionEnabled is present in the client performance options table but its not present on the client performance options form.


Method isDeferredDeletionEnabled from table SysClientPerf table does the check where, if the feature is not  enabled through feature management  but enabled  in document management parameter then its gets disabled automatically. So make sure to enabled it from feature management and parameters form , other wise you wont be able to see deleted document attachments on the new form.

Whenever we attach any document on the form the records get inserted in DocuRef and DocuValue Tables. Before this feature there was no way to recover deleted documents unless you do  have some customizations where you are storing values from these tables and  using those for recovery. Well if you are doing it  , you don’t need it now because this feature takes care of it.

So whenever you delete any attachment form any form after enabling this feature, the values get inserted in new tables DocuDeletedRef and DOCUDELETEDVALUE which corresponds to the table DocuValue and Docuref. If you want to see how the values gets inserted in this table take a look at insert method of Docuref table, following piece of code is responsible for  putting these value on Deleted attachments form.Fullscreen12345678// If deferred deletion is enabled, update the DocuDeletedRef table. SysClientPerf sysClientPerf; sysClientPerf = SysClientPerf::find(false); DocuDeletedRef docuDeletedRef; if (sysClientPerf.isDeferredDeletionEnabled()) { docuDeletedRef.insert(this); }

Once you delete attachment from any form , you can navigate to a from System Administration >   Deleted attachments to see it. 

Another way to open this form is through Document management parameters form.


Navigation from attachments form:

The attachment form also have button “Deleted attachment” which shows deleted documents related to selected base table  record.


Technical solution behind the restore button is very simple. restoreDeletedRecord method on DocuDeletedRef table is responsible for  restoring all selected attachments to the respective base table records.

While deleting the attachment , if you want to show user about  for how may days file is going to be retain on attachments screen  , enable “Ask for confirmation” check box on document type form.


Once you enable this system is going to notify users about retention days for the document they are deleting


Clean up of attachments which pass retention  days

When we  enable deferred deletion from Document management parameters , the new batch job gets added  in the system with name “Scans for deleted references which have reached the end of their retention period.”

If you want to see how the batch job gets added in the system , take a look at class DocumentManagementSetup  method scheduleDeferredDeletionRetentionPeriodScan. This method is nothing but ModifiedField event of the table SysClientPerf


Security Role :

The new security role “Deleted documents administrator form” is introduced in the application , which controls the access to  new form.

The official documentation for this feature can be found on the  this link. Feel free to comment , if you have any questions.