Document Register: Moving digital documents into a Document Register Matter

Document Register: Moving digital documents into a Document Register Matter

  1. /*
  2. This script is a template that will help you move library documents
  3. (document register / safe custody records) into a general 'Document Register' matter.

  4. You should consider this a TEMPLATE that you may
  5. want to tweak and adjust for each client's specific needs.

  6. */

  7. --Create Subfolders for Matter packets
  8. UPDATE
                   __M_Documents_Digital_Files
  9. SET
  10.                Final_FolderName = CONCAT('\', Contact.Final_FullName, '\', Matter.Final_ReferenceCode, ' --- ', Matter.Final_Description, Final_FolderName),
  11.                Final_Parent_Id = '__DOCUMENT_REGISTER',
                   Final_Parent_Type = '__M_Matters'
  12. FROM
  13.                 __M_Documents_Digital_Files V0,
                   __M_Documents_Physical_Files LD,
                   __M_Documents_Physical_Folders LF,
                   __M_Matters Matter,
                   __M_Contacts Contact
  14. WHERE 1=1
  15.                 AND V0.Final_Parent_Type = '__M_Library_Documents'
  16.                 AND V0.Final_Parent_Id = LD.Id
  17.                 AND LD.Final_LibraryFolder_Id = LF.Id
  18.                 AND LF.Final_Parent_Type = '__M_Matters'
  19.                 AND LF.Final_Parent_Id = Matter.Id
  20.                 AND Matter.Final_ClientContact_Id = Contact.Id
  21.                 
  22. --Create subfolders for contact packets
  23. UPDATE
  24.                 __M_Documents_Digital_Files
  25. SET
  26.                 Final_FolderName = CONCAT('\', Contact.Final_FullName, '\', 'Contact Register', Final_FolderName),
  27.                 Final_Parent_Id = '__DOCUMENT_REGISTER',
  28.                 Final_Parent_Type = '__M_Matters'
  29. FROM
  30.                  __M_DocumentFiles V0,
  31.                 __M_Documents_Physical_Files LD,
  32.                 __M_Documents_Physical_Folders LF,
  33.                 __M_Contacts Contact
  34. WHERE 1=1
  35.                  AND V0.Final_Parent_Type = '__M_Library_Documents'
  36.                 AND V0.Final_Parent_Id = LD.Id
  37.                 AND LD.Final_LibraryFolder_Id = LF.Id
  38.                 AND LF.Final_Parent_Type = '__M_Contacts'
  39.                 AND LF.Final_Parent_Id = Contact.Id
  40.                 
  41. --Now create the document register matter
  42. INSERT INTO __M_Matters(
  43.                 Id, Final_ClientContact_Id, Final_Subject
  44. ) VALUES (
  45.                 '__DOCUMENT_REGISTER', '__INTERNAL', 'Document Register'
  46.                   )

  47. --(OPTIONAL) Rename the digital documents to have names that match the physical documents
  48. UPDATE
  49.                 __M_Documents_Digital_Files
  50. SET
  51.                 Final_FileName = CONCAT(V1.Final_Type, ' --- ', V1.Final_Subject, ' --- ', FORMAT(V1.Final_Date, 'yyyy-MM-dd') )
  52. FROM
  53.                 __M_Documents_Digital_Files V0,
  54.                 __M_Documents_Physical_Files V1
  55. WHERE 1=1
  56.                 AND V0.Final_Parent_Type = '__M_Library_Documents'
  57.                 AND V0.Final_Parent_Id = V1.Id



    • Related Articles

    • Moving Documents into Matters that are Nested under Other Entries

      Some systems allow documents to be nested under virtually any other kind of record. This can be challenging when moving documents into systems that have a limited number of parent types. --The following script creates a "MISC DOCUMENTS" matter --And ...
    • Promoting Document Versions into Documents

      --The following playbook is a TEMPLATE that you can use to promote all document versions into actual documents. --When a document has a category, append the folder with the document category ID. UPDATE __M_Documents_Digital_Files SET --Prepend the ...
    • Synthesize: Missing Document Categories for Documents

      The following script will synthesize document categories for invalid Final_DocumentCategory_Id values on documents. -- Some documents are linked to categories that no longer exist. -- Create dummy document categories based on these values. INSERT ...
    • Synthesize Missing Matters for Documents

      Some systems only allow documents to be linked to matters. These scripts will allow you to restore data into these systems. When Matters No Longer Exist The following script with synthesize matters for document related to matters that no longer ...
    • Moving Documents into Matters that are Nested under Calendar Entries

      --The following script moves documents that are nested under Calendar Entries to be nested under Matters instead. UPDATE __M_Documents_Digital_Files SET Final_Folder_RelativePath = '\Calendar Attachments\', Final_Parent_Type = ...