Moving Documents into Matters that are Nested under Invoices

Moving Documents into Matters that are Nested under Invoices



  1.  --The following script moves documents that are nested under Invoices to be nested under Matters instead.
  2. UPDATE
  3. __M_Documents_Digital_Files
  4. SET 
  5. Final_Folder_RelativePath = '\Invoices\',
  6. Final_Parent_Type = Relationships.Final_RelatedTo_Type,
  7. Final_Parent_Id = Relationships.Final_RelatedTo_Id
  8. FROM
  9. __M_Documents_Digital_Files Documents,
  10. __M_Financial_AR_Invoices Parents,
  11. __M_Financial_AR_Invoices_Related_Entities Relationships
  12. WHERE 1=1
  13. AND Documents.Final_Parent_Type = '__M_Financial_AR_Invoices'
  14. AND Documents.Final_Parent_Id = Parents.Id
  15. AND Parents.Id = Relationships.Final_ArInvoice_Id
  16. AND Relationships.Final_RelatedTo_Type = '__M_Matters'