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

Batch copying solutions to new cases


I have a request to have a trigger create a new case if a user adds a comment to a closed case via the portal or email 2 case.  As part of this they would like any existing solutions added to the new case(s).

My question is what is the best way to bulkify this behaviour?  OK, so in this scenario, there should only be one update at a time, but as we know we should bulkify our trigger code.

I'm creating a list of new cases and then inserting that list, the problem comes with then trying to associate the solutions from the old cases to the new cases, is there a "standard" way of doing this?


Best Answer chosen by DaveKemp
You can use maps to bulkify the code. You can map a caseId with a solution record and then retrieve the solution Id to assign it to the new case. These list cases can all be inserted once.