SQL Spreadsheets: Cherry-Picking Custom Fields

SQL Spreadsheets: Cherry-Picking Custom Fields

The following SQL command will generate a Google Sheet that users can use to cherry-pick custom field definitions.

  1. SELECT
  2. '' as 'Keep? (Y)',
  3. V1.Id,
  4. V1.Final_Parent_Type,
  5. V1.Final_Kind,
  6. V1.Final_Subject,
  7. V1.Final_Description, V1.Final_Status,
  8. COALESCE(V2.Count, 0) as 'TimesUsed',

  9. Script = CONCAT(''
  10. --IF cell A### = "Y"
  11. , '=IF(INDIRECT("A"&ROW()) = "Y",'
  12. --THEN: Generate the script using the ID in cell B###.
  13. , '"'
  14. , ' UPDATE'
  15. , ' __M_CustomField_Definitions'
  16. , ' SET'
  17. , ' Final_Status = ''Active'', '
  18. , ' Final_Subject = '
  19. , ' ''" & '
  20. , ' SUBSTITUTE(INDIRECT("E"&ROW()), "''", "''''") '
  21. , ' & "'''
  22. , ' WHERE 1=1'
  23. , ' AND Id = '
  24. , ' ''" & '
  25. , ' INDIRECT("B"&ROW()) '
  26. , ' & "'''
  27. , '"'
  28. --/THEN
  29. , ', '
  30. --ELSE
  31. , '"'
  32. , ' '
  33. , '"'
  34. --/ELSE
  35. , ')'
  36. )
  37. FROM
  38. __M_CustomField_Definitions V1
  39. LEFT JOIN
  40. (
  41. SELECT
  42. Final_CustomFieldDefinition_Id as 'Id',
  43. Count(*) as 'Count'
  44. FROM
  45. __M_CustomField_Values
  46. GROUP BY
  47. Final_CustomFieldDefinition_Id
  48. ) AS V2
  49. ON V1.Id = V2.Id
  50. ORDER BY
  51. Final_Parent_Type, Final_Subject

 
Once you generate the Google Sheet, you should share it with your customer with instructions similar to the following:
Replace references to the "legacy environment" and "new system" to be the actual names of the systems.

---

Hi Customer,

In prep for restoring your data to the [new system], I need you to fill out the Google Sheet included in this email.

The spreadsheet lists all custom field definitions your firm has defined and how many times each one is used.

For each field that you would like to keep, place a in column A.

When choosing each field, you should only select the fields that are important and frequently used.

For example, if you have a field that you feel is important but is seldom used, use your own judgement, but we generally recommend not cluttering your new system with it.


If you have any questions, please feel free to reach out.


    • Related Articles

    • SQL Spreadsheets: Cherry-Picking Records

      As a general rule, we recommend that SQL scripts be used to mass-select/prune records; however, sometimes that is not possible. In these cases, we recommend having a member of the law firm complete a Google spreadsheet that clearly indicates what ...
    • SQL Spreadsheets: Cherry Picking Matters

      The following SQL command will generate a spreadsheet that can be used to cherry-pick specific matters. CREATE OR ALTER FUNCTION SafeSingleLine ( @Input NVARCHAR(MAX) ) RETURNS NVARCHAR(MAX) AS BEGIN DECLARE @Ret NVARCHAR(MAX) = COALESCE(@Input, '') ...
    • SQL Spreadsheets: DocType Mappings

      The following SQL script will generate a Google Spreadsheet that will allow users to override document category names. This is extremely helpful when merging systems. SELECT V1.Id, V1.Final_ReferenceCode as 'Old Code', V1.Final_Subject as 'Old Name', ...
    • SQL Spreadsheets: User Mappings

      The following SQL script will generate a Google Spreadsheet that will allow users to override email addresses. This is extremely helpful when merging old user accounts together. SELECT V1.Id, V1.Final_FullName as 'Old User (FullName)', ...
    • SQL Spreadsheets: Reassigning Practice Areas

      Sometimes users want to reassign practice areas as part of the data restore into a new system. The following process makes it easy. Generate the SQL Spreadsheet Run the following command then copy the results and the headers into a Google Doc. ...