You need to sign in to do that
Don't have an account?
Merge a collection - how do you?
Hi,
I am trying to bulkify a trigger that merges incoming Leads based on a matched email so that the merge DML operation does not have to be executed in a for loop.
trigger LeadMerge on Lead (after insert) {
for (lead l: trigger.new){
try{
Lead mId = [select id from Lead where email = :l.email limit 1];
merge mId l.id;
I can't figure out how to build a collection that can be used in the merge statement to return the pair of Lead IDs to be merged. If I build a map that holds the master ID and the matched record, how do I get the key-value pair to be returned in a way that the merge statement can process it?
Thanks for any help