Find your content:

Search form

You are here

What options are available to prevent duplicate entries?

 
Share

I am working to help minimize the appearance of duplicate accounts within our Salesforce environment. One alternative I found was to create a hidden field as a validation check - if that field is set to unique, and is attempted to be set as something which is a duplicate, it throws an error.

The problem, however, is that we have multiple systems interacting with Salesforce, one of which creates duplicate entries. I'm currently looking into writing a trigger where on an account creation/update, it checks for a duplicate entry, and if it finds one, merges the two together. Is it possible for triggers to fire off a merge? Or do I need to write in for all of the fields to port over?

Is there an alternative I am missing?


Attribution to: Plastinko

Possible Suggestion/Solution #1

We have merge Call in triggers

merge triggers fire both before and after delete triggers for the losing records and before update triggers for the winning record only

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_merge_statements.htm

List<Account> ls = new List<Account>{
new Account(Name='Acme Inc.'),
new Account(Name='Acme')};
insert ls;
Account masterAcct = [SELECT Id, Name
FROM Account WHERE Name = 'Acme Inc.'
LIMIT 1];
Account mergeAcct = [SELECT Id, Name FROM
Account WHERE Name = 'Acme' LIMIT 1];
try { merge masterAcct mergeAcct;
 } catch (DmlException e) {
// Process exception here
 }

Attribution to: Mohith Shrivastava

Possible Suggestion/Solution #2

There are various 3rd party applications that are designed to deal with this (just search the App Exchange). I believe many of them use the same method of detection, which is to search specified fields and see if any results are returned, e.g. an example would be for a unique combination of name and email address.

You could implement something similar with Triggers, checking for the duplicates and preventing creation, though I would caution against automatic merging. If your integration handled the merging you would need to be 100% certain that the correct data was being saved between the records.

Another option would be if these other systems have unique identifiers that you could utilize inside Salesforce.


Attribution to: Mike Chale

Possible Suggestion/Solution #3

Merge exists in apex, but it does count as a DML operation and thus will use one of your DML limits for the transaction. You'll want to make sure that you use good bulk trigger best practices if you use a trigger.

But there is a fundamental problem with doing this on a trigger.

Trigger.new is a max size of 200 records. There is no visibility between two sets of 200 records on an API call. If an API call loads 400 records, the dupe might sit in two different trigger batches.

I would recommend implementing this as batch apex that is scheduled to execute a certain number of times per day.


Attribution to: pchittum

Possible Suggestion/Solution #4

While I'm sure you can write your own triggers, if you've got large volumes to dedupe against and your dedupe needs are more than a simple Account Merge, you're probably better off looking at an app exchange solution.

There is a free one called DupeCatcher tha tends to be quite popular http://appexchange.salesforce.com/listingDetail?listingId=a0N30000003IYLlEAO

Equally there are some great paid solutions. I've implemented DupeBlocker by CRM Fusion which allows you to configure a good number of dupe catching scenarios (Lead-Lead, Lead-Account, Account - Account etc) with configurable error messages and behaviour (block, notify and merge). It catches out dupes by firing triggers off dml events which calculates dedupe keys and indexes them


Attribution to: techtrekker
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/2259

My Block Status

My Block Content