Create a "Legacy Client Number" Custom Field

Create a "Legacy Client Number" Custom Field

Some firms rely heavily on Client Numbers to search for a specific client.  Sometimes when they migrate to a new system it can't replicate the automatic numbering system from their old system so they want to renumber all their matters to a new scheme that the new system CAN support.  However, they may also want to preserve the old client numbers so they can search for clients using those numbers.

The script below will create a custom field named 'Legacy Client Number' and populate it with the client numbers from their source system.

  1. INSERT INTO __M_CustomField_Definitions (
  2. Id,
  3. Final_Kind,
  4. Final_Subject,
  5. Final_Parent_Type
  6. )
  7. VALUES (
  8. 'Legacy Client Number',
  9. 'TextLine',
  10. 'Legacy Client Number',
  11. '__M_Contacts'
  12. )

  13. INSERT INTO __M_CustomField_Values (
  14. Id,
  15. Final_Parent_Id,
  16. Final_Parent_Type,
  17. Final_CustomFieldDefinition_Id,
  18. Final_Value
  19. )
  20. SELECT
  21. CONCAT('Legacy Client Number --- ', Id),
  22. Id,
  23. '__M_Contacts',
  24. 'Legacy Client Number',
  25. Final_ReferenceCode
  26. FROM
  27. __M_Contacts
  28. WHERE 1=1
  29. AND LEN( Final_ReferenceCode ) > 0