function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Apex Reopen Case and Copy Previous Comments

I have a trigger that reopens a case and copies all info into a new case number. Anyone know how I can copy the comments out of the old case into the new one?

Here's what you should do:

- after creating the new case, query Salesforce to retrive all the comments related to the original case and put it into a list

- Go through each comment in the list, and perform a deep clone (clone( false, true ); ) on each commnent and add the cloned comment to a new list.

- insert that new list that contains all the new cloned comments