Flatten Custom Object fields into Contact/Matter Fields

Flatten Custom Object fields into Contact/Matter Fields

Warning
WARNING:
Many systems that support custom objects allow multiple rows in custom objects.
Many systems that allow custom fields only allow one single value for each field.
When you use this script, if a matter has two values set for the same custom field, only one will be used.

  1. --Update the custom field definitions to link to contacts/matters.
  2. UPDATE
  3. __M_CustomField_Definitions
  4. SET
  5. Final_Parent_Type = V4.Final_RelatedTo_Type
  6. FROM
  7. __M_CustomField_Definitions V1,
  8. __M_CustomObject_Definitions V2,
  9. __M_CustomObject_Instances V3,
  10. __M_CustomObject_Instances_Related_Entities V4
  11. WHERE 1=1
  12. AND V1.Original_Parent_Type = V2.Id
  13. AND V2.Id = V3.Original_CustomObjectDefinition_Id
  14. AND V3.Id = V4.Original_CustomObjectInstance_Id

  15. --Update the values to have new parent types.
  16. UPDATE
  17. __M_CustomField_Values
  18. SET
  19. Final_Parent_Type = V3.Final_RelatedTo_Type,
  20. Final_Parent_Id = V3.Final_RelatedTo_Id
  21. FROM
  22. __M_CustomField_Values V1,
  23. __M_CustomObject_Instances V2,
  24. __M_CustomObject_Instances_Related_Entities V3
  25. WHERE 1=1
  26. AND V1.Original_Parent_Id = V2.Id
  27. AND V1.Original_Parent_Type = V2.Original_CustomObjectDefinition_Id
  28. AND V2.Id = V3.Original_CustomObjectInstance_Id
  29. a


    • Related Articles

    • Convert User-Select/Contact-Select Custom Fields => Participants

      Some systems do not support User-Select or Contact Select custom fields. The following query will transform User-Select fields into Matter Participants. This script can easily be adapted for Contact-Select fields. -- Transform Custom Fields on ...
    • Custom Fields: Creating Custom Fields via Queries

      Sometimes you may need to create a new custom field to handle an unmapped column in a database. The queries below will help you do that. -- This is the ID we are giving our custom field definition. DECLARE @FieldId NVARCHAR(MAX) = 'ConNo --- CUSTOM' ...
    • Copy User and Contact Picklists from __M_CustomField_Definitions to __M_Matters_Participating_Entities

      Some systems do not support custom fields that are User/Contact Picklist but they do support participants. Use this script to copy custom field values/definitions into the Matter Participants table. --We need to copy some records from custom fields ...
    • Matter Participants: Data Cleanup

      Table Overview Matter Participants are contacts that are related to Matters. They exist in the table: __M_Matters_Participating_Entities They have three primary fields: Field Description Final_Matter_Id The Id of the Matter. Final_Participant_Type ...
    • Create a "Legacy Matter Number" Custom Field

      Some firms rely heavily on Matter Numbers to search for a specific matter. 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 ...