Document Register: Moving digital documents into a Document Register Matter
- /*
- This script is a template that will help you move library documents
- (document register / safe custody records) into a general 'Document Register' matter.
- You should consider this a TEMPLATE that you may
- want to tweak and adjust for each client's specific needs.
- */
- --Create Subfolders for Matter packets
- UPDATE
__M_Documents_Digital_Files - SET
- Final_FolderName = CONCAT('\', Contact.Final_FullName, '\', Matter.Final_ReferenceCode, ' --- ', Matter.Final_Description, Final_FolderName),
- Final_Parent_Id = '__DOCUMENT_REGISTER',
Final_Parent_Type = '__M_Matters' - FROM
- __M_Documents_Digital_Files V0,
__M_Documents_Physical_Files LD,
__M_Documents_Physical_Folders LF,
__M_Matters Matter,
__M_Contacts Contact - WHERE 1=1
- AND V0.Final_Parent_Type = '__M_Library_Documents'
- AND V0.Final_Parent_Id = LD.Id
- AND LD.Final_LibraryFolder_Id = LF.Id
- AND LF.Final_Parent_Type = '__M_Matters'
- AND LF.Final_Parent_Id = Matter.Id
- AND Matter.Final_ClientContact_Id = Contact.Id
-
- --Create subfolders for contact packets
- UPDATE
- __M_Documents_Digital_Files
- SET
- Final_FolderName = CONCAT('\', Contact.Final_FullName, '\', 'Contact Register', Final_FolderName),
- Final_Parent_Id = '__DOCUMENT_REGISTER',
- Final_Parent_Type = '__M_Matters'
- FROM
- __M_DocumentFiles V0,
- __M_Documents_Physical_Files LD,
- __M_Documents_Physical_Folders LF,
- __M_Contacts Contact
- WHERE 1=1
- AND V0.Final_Parent_Type = '__M_Library_Documents'
- AND V0.Final_Parent_Id = LD.Id
- AND LD.Final_LibraryFolder_Id = LF.Id
- AND LF.Final_Parent_Type = '__M_Contacts'
- AND LF.Final_Parent_Id = Contact.Id
-
- --Now create the document register matter
- INSERT INTO __M_Matters(
- Id, Final_ClientContact_Id, Final_Subject
- ) VALUES (
- '__DOCUMENT_REGISTER', '__INTERNAL', 'Document Register'
- )
- --(OPTIONAL) Rename the digital documents to have names that match the physical documents
- UPDATE
- __M_Documents_Digital_Files
- SET
- Final_FileName = CONCAT(V1.Final_Type, ' --- ', V1.Final_Subject, ' --- ', FORMAT(V1.Final_Date, 'yyyy-MM-dd') )
- FROM
- __M_Documents_Digital_Files V0,
- __M_Documents_Physical_Files V1
- WHERE 1=1
- AND V0.Final_Parent_Type = '__M_Library_Documents'
- AND V0.Final_Parent_Id = V1.Id