The following SQL command will generate a Google Sheet that users can use to cherry-pick custom field definitions.
- SELECT
- '' as 'Keep? (Y)',
- V1.Id,
- V1.Final_Parent_Type,
- V1.Final_Kind,
- V1.Final_Subject,
- V1.Final_Description, V1.Final_Status,
- COALESCE(V2.Count, 0) as 'TimesUsed',
- Script = CONCAT(''
- --IF cell A### = "Y"
- , '=IF(INDIRECT("A"&ROW()) = "Y",'
- --THEN: Generate the script using the ID in cell B###.
- , '"'
- , ' UPDATE'
- , ' __M_CustomField_Definitions'
- , ' SET'
- , ' Final_Status = ''Active'', '
- , ' Final_Subject = '
- , ' ''" & '
- , ' SUBSTITUTE(INDIRECT("E"&ROW()), "''", "''''") '
- , ' & "'''
- , ' WHERE 1=1'
- , ' AND Id = '
- , ' ''" & '
- , ' INDIRECT("B"&ROW()) '
- , ' & "'''
- , '"'
- --/THEN
- , ', '
- --ELSE
- , '"'
- , ' '
- , '"'
- --/ELSE
- , ')'
- )
- FROM
- __M_CustomField_Definitions V1
- LEFT JOIN
- (
- SELECT
- Final_CustomFieldDefinition_Id as 'Id',
- Count(*) as 'Count'
- FROM
- __M_CustomField_Values
- GROUP BY
- Final_CustomFieldDefinition_Id
- ) AS V2
- ON V1.Id = V2.Id
- ORDER BY
- 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 Y 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.