CiviCoop have produced a wonderful extension, Documenten, which provides some great new features for adding attachments to Case Activities and storing them in a user-friendly way (a Documents tab on the Contact record), as well as the ability to update files with newer versions of the file. Some of the extensions features were only functioning when Cases and Activities were being created through the Webform CiviCRM feature.
After trialling the extension we found that the client needed some enhancements to provide more flexibility - or consistency - in terms of how attachments could be added, rather than just through the Webform interface.
With our tweaks to the extension it is now possible to add documents to the 'document library' directly via CiviCase, as well as via Webform, and via Inbound Emails. The process works whether the attachments are being added to the Case itself, or to Activities on the Case, when 'Filing' an existing Activity on to a Case, as well as when copying an activity with an attachment from one case to another case.
We also wanted to improve the 'labelling' of these attachments so we added a ‘subject’ option to the webform module. Therefore when a case/activity on a case document field is enabled via webform there is a checkbox for “Save this file as a document in civicrm”. If this is checked, a subject field is added to the webform. If checkbox is un-checked, the subject field is deleted.
If someone is completing the webform and fills out the subject field, this is saved with the document and displays on the Document tab on the contact. This works whether the file is being added to the case, or to an activity on a case. If there are multiple attachments, each get their own subject field.
A few other issues we hit and worked our way around included:
The View module provides the document id that is being added to the case. However the download link for the file was not available on a created custom view, only in the default View enabled with the extension. This was because “civicrm_entitiy_file” wasn’t available in a custom view. We used code in a ‘global php’ field within the View in order to display the download link.
We found that permissions were not being applied to who can access the files. This meant users with permission to see the Contact were seeing Documents that were linked to Cases, even if they did not have Case permissions. We updated extension to only show civicrm_document_case table if the user is involved with the Case or has permission of either “administer civicase” or “access all case and activities”.
When a file was updated with a new revision the date updated field was only storing Date, not Time as well. We updated this to store the date related fields in datetime() format.
We wanted all documents that had been added to cases prior to us enabling the extension to also show in the documents tab(s). This was possible using a script to add all previous activities with attachments and adding them as documents, and a second script to update their subjects to match their file names.
There were issues with the Subject coming through when Activities were being added via Email, or moved from Case to Case, of Filed on a Case, etc, etc. We were able to resolve all of these, other than when an activity is via an inbound email, where the subject does not come through as the file label.
Big thanks to the work CiviCoop
did on this possible little known gem of an extension. Hopefully with our additions this extension may find wider audience as a step towards a 'file management' system for CiviCase.