Copy a Custom Field into a Core Field

Copy a Custom Field into a Core Field

Some systems don't have certain core fields and clients often create a custom field that they use instead.  The following script will let you copy values from a custom field named 'Opened' into __M_Matters.Final_Date_Opened .  You can adjust this template as you see fit.

  1. --In our Source system, Matter's don't have an Opened date
  2. --But our client created a custom field named 'Opened'.
  3. --We are going to copy that value into the Matter's Final_Date_Opened
  4. UPDATE
  5. __M_Matters
  6. SET
  7. Final_Date_Opened = V2.Final_Value
  8. FROM
  9. __M_CustomField_Definitions V1,
  10. __M_CustomField_Values V2,
  11. __M_Matters V3
  12. WHERE 1=1
  13. AND V1.Final_Subject = 'Opened'
  14. AND V1.Final_Parent_Type = '__M_Matters'
  15. AND V2.Final_CustomFieldDefinition_Id = V1.Id
  16. AND V2.Final_Parent_Type = V1.Final_Parent_Type
  17. AND V3.Id = V2.Final_Parent_Id