Some systems support note comments(notes-on-notes). On systems like this, you might see notes organized as follows:
- |-Matter ABC.001
- +-Note 1 (2021-01-01)
- +-Note 2 (2021-01-02)
- +-Note 2A (2021-01-04)
- +-Note 2B (2021-01-05)
- +-Note 2C (2021-01-06)
- +-Note 3 (2021-01-03)
The following script will detect notes on notes and move them directly under a contact or matter root.
This is necessary when restoring notes into systems that do not support note comments, however, you should advise your client that the hierarchical context will not be preserved so notes may render in a suboptimal order such as:
- |-Matter ABC.001
- +-Note 1 (2021-01-01)
- +-Note 2 (2021-01-02)
- +-Note 3 (2021-01-03)
- +-Note 2A (2021-01-04)
- +-Note 2B (2021-01-05)
- +-Note 2C (2021-01-06)
The Script
- --Convert Notes-On-Notes to be a linear list of notes
- DECLARE @RESULTS INT = -1WHILE(@RESULTS != 0) BEGIN UPDATE Child
- SET
- --Change the Child's parent to the Parent's Parent
- Child.Final_Parent_Id = Parent.Final_Parent_Id, Child.Final_Parent_Type = Parent.Final_Parent_Type
- FROM
- __M_Common_Notes Parent,
- __M_Common_Notes Child WHERE 1=1 --Only do this for Notes-on-Notes AND Child.Final_Parent_Id = Parent.Id AND Child.Final_Parent_Type = '__M_Common_Notes' --That have a "Root" note attached to one of the following type AND Parent.Final_Parent_Type IN ('__M_Contacts', '__M_Matters')
- SET @RESULTS = @@ROWCOUNT
- END
- GO