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 then moves any documents that do not have a valid Parent Type into this matter.
- GO
- DECLARE @Id NVARCHAR(MAX) = 'MISC DOCUMENTS'
- DELETE FROM __M_Matters WHERE Id = @Id
- INSERT INTO __M_Matters (Id, Final_Subject)
- VALUES (@Id, @Id)
- UPDATE
- __M_Documents_Digital_Files
- SET
- Final_Parent_Id = @Id,
- Final_Parent_Type = '__M_Matters',
- Final_Folder_RelativePath = CASE
- WHEN COALESCE(Final_Created_At, Final_Updated_At) IS NULL THEN CONCAT('\', Final_Parent_Type, Final_Folder_RelativePath)
- ELSE CONCAT('\', Final_Parent_Type, '\', FORMAT( COALESCE(Final_Created_At, Final_Updated_At), 'yyyy-MM'), Final_Folder_RelativePath)
- END
- WHERE 1=1
- AND Final_Parent_Type NOT IN (
- --Update this to have the list of valid document Parent Types for your destination.
- '__M_Contacts',
- '__M_Matters'
- )