Scenario:(I have translated it to accounts & contacts, actually are custom objs)-

I have decided that the contacts with the same name under are account are duplicated. Hence I have written a trigger on contacts, before insert & before update, to weed out those duplicate contacts by comparing them with existing contact records. Then I create a List that contains non duplicate contact records and it is then this list I use for the remaining processing in the contact trigger.

Now I have decided to use the salesforce duplication rules to do the deduplication rather than the trigger(Owing to increasing records in the system). But if I do it, then I lose the deduplicated List that I was using in the rest of the trigger. Since duplication rules run only after the before trigger is executed, all the entries in trigger.new( even duplicates) will be considered in trigger.new.

Is there anyway I can prevent the trigger from operating on the duplicate records in trigger.new, if I leave the deduplication part to duplicate rules and not the trigger?

PS : Moving the before insert & before update functionalities to after trigger is not a good design since, I am updating the trigger.new in some of those methods.

Thanks in advance

  • 1
    You can move the logic to after triggers and use future methods to update the trigger.new values. – Vigneshwaran G Apr 28 '16 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.