+ Start a Discussion
DaveKempDaveKemp 

Batch copying solutions to new cases

Hi,

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?

Thanks,
David

Best Answer chosen by DaveKemp
ShashForceShashForce
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.