Moving Documents into Matters that are Nested under Other Entries

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.



  1. --The following script creates a "MISC DOCUMENTS" matter
  2. --And then moves any documents that do not have a valid Parent Type into this matter.

  3. GO

  4. DECLARE @Id NVARCHAR(MAX) = 'MISC DOCUMENTS'
  5. DELETE FROM __M_Matters WHERE Id = @Id
  6. INSERT INTO __M_Matters (Id, Final_Subject)
  7. VALUES (@Id, @Id)

  8. UPDATE
  9. __M_Documents_Digital_Files
  10. SET
  11. Final_Parent_Id = @Id,
  12. Final_Parent_Type = '__M_Matters',
  13. Final_Folder_RelativePath = CASE 
  14. WHEN COALESCE(Final_Created_At, Final_Updated_At) IS NULL THEN CONCAT('\', Final_Parent_Type, Final_Folder_RelativePath)
  15. ELSE CONCAT('\', Final_Parent_Type, '\', FORMAT( COALESCE(Final_Created_At, Final_Updated_At), 'yyyy-MM'), Final_Folder_RelativePath)
  16. END
  17. WHERE 1=1
  18. AND Final_Parent_Type NOT IN (
  19. --Update this to have the list of valid document Parent Types for your destination.
  20. '__M_Contacts',
  21. '__M_Matters'
  22. )


    • Related Articles

    • 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 = ...
    • Moving Documents into Matters that are Nested under Communications

      --The following script moves documents that are nested under Communications to be nested under Matters instead. UPDATE __M_Documents_Digital_Files SET Final_Folder_RelativePath = '\Emails\', Final_Parent_Type = Relationships.Final_RelatedTo_Type, ...
    • Moving Documents into Matters that are Nested under Tasks

      --The following script moves documents that are nested under Tasks to be nested under Matters instead. UPDATE __M_Documents_Digital_Files SET Final_Folder_RelativePath = '\Task Attachments\', Final_Parent_Type = Relationships.Final_RelatedTo_Type, ...
    • Moving Documents into Matters that are Nested under Invoices

      --The following script moves documents that are nested under Invoices to be nested under Matters instead. UPDATE __M_Documents_Digital_Files SET Final_Folder_RelativePath = '\Invoices\', Final_Parent_Type = Relationships.Final_RelatedTo_Type, ...
    • 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 ...