- --The system we are coming from does not have practice areas
- --however, the client has created a picklist custom field that mimics this.
- --We are going to convert this custom field into a practice area.
- --First, populate the practice areas table with our new values.
- INSERT INTO __M_Matters_PracticeAreas(
- Id,
- Final_Subject
- )
- SELECT
- V2.Id,
- V1.Final_Subject
- FROM
- __M_CustomField_Definitions V1,
- __M_CustomField_Definitions_Options V2
- WHERE 1=1
- --Change this to be the name of the custom field we're converting into a practice area
- AND V1.Final_Subject = 'Case Type'
- AND V1.Final_Parent_Type = '__M_Matters'
- AND V1.Final_Kind = 'PickList'
- AND V2.Final_CustomFieldDefinition_Id = V1.Id
- --Now, update our matters to use these practice areas.
- UPDATE
- __M_Matters
- SET
- Final_PracticeArea_Id = V2.Id
- FROM
- __M_CustomField_Definitions V1,
- __M_CustomField_Definitions_Options V2,
- __M_CustomField_Values V3,
- __M_Matters V4
- WHERE 1=1
- --Change this to be the name of the custom field we're converting into a practice area
- AND V1.Final_Subject = 'Case Type'
- AND V1.Final_Parent_Type = '__M_Matters'
- AND V1.Final_Kind = 'PickList'
- AND V2.Final_CustomFieldDefinition_Id = V1.Id
- AND V2.Id = V3.Final_Value
- AND V3.Final_CustomFieldDefinition_Id = V1.Id
- AND V3.Final_Parent_Type = V1.Final_Parent_Type
- AND V3.Final_Parent_Id = V4.Id