0

I created a matching rule and duplicate rule regarding lead company name and i tested by creating records with company name as test and test data The record is saving without showing any duplicates found. For reference please find below screenshots .Is there any other way to achieve this. enter image description here

enter image description here

Trigger DuplicateLeadPreventer on Lead (before insert, before update) {

//Since only certain leads will match, put them in a separate list List LeadstoProcess = new List ();

//Company to Lead Map Map leadMap = new Map();

for (Lead lead : Trigger.new) {

//Only process for Leads in our RecordTypeMap


   // Make sure we don't treat an Company name that
  // isn't changing during an update as a duplicate.

         if (
            (lead.company != null) &&
            (Trigger.isInsert ||
            (lead.company != Trigger.oldMap.get(lead.Id).company))
            )
            {

               // Make sure another new lead isn't also a duplicate

                   if (leadMap.containsKey(lead.company)) {
                       lead.company.addError('Another new lead has the '
                                       + 'same company name.');
                   } else {
                       leadMap.put(lead.company , lead);
                       LeadstoProcess.add(lead);

           }

} //end RT If Check } //End Loop

/* Using a single database query, find all the leads in the database that have the same company address as any of the leads being inserted or updated.

*/

Set ExistingCompanies = new Set ();

       for (Lead l: [Select Id, Company from Lead WHERE Company IN :leadMap.keyset()]) {
                     ExistingCompanies.add(l.Company);
           }

//Now loop through leads to process, since we should only loop if matches /* for (Lead l : LeadstoProcess) { if (ExistingCompanies.contains(l.company) ) { l.company.addError('A lead with this company ' + 'name already exists.'); } */

}

0

I don't think the word "data" would be stripped for the sake of fuzzy matching in a company name, as that would likely be a definitive word in the name. For instance you probably would not want a match between "Data Pros" and "The Pros, Inc." ("the" and "inc." would be removed in fuzzy) in a live scenario. What are some real use cases you are trying to capture?

You can see some basic description behind SF fuzzy matching logic here:

https://help.salesforce.com/articleView?id=matching_rules_matching_methods.htm&type=5

Specifically, on fuzzy matching for company name:

Removes words such as “Inc” and “Corp” before comparing fields. Also, company names are normalized. For example, “IBM” is normalized to “International Business Machines”.

7
  • The leads must allow duplicates company ,it must display the duplicate records and save the record.Client has 10,000 leads at present they need to see the duplicates using fuzzy . – Helcyon Apr 25 '20 at 8:57
  • I already raised ticket to Salesforce Team they suggested not to use fuzzy .They explained that there are some bugs regarding fuzzy .They ask me to upvote the idea to implement.Can you help me how can we acheive this issue by Customization whether we need to implement aura components or trigger etc. – Helcyon Apr 25 '20 at 9:04
  • Sure, can you elaborate on how your matching criteria should work? More examples of should-be matches would help too. – Brig Larimer Apr 25 '20 at 17:35
  • Company name must allow duplicates with fuzzy logic for Example :If Company name is Krishna Pipes for one record and other record name as krishna it must show duplicates and save the record.Indirectly in a new record company name contains any old record company name means it must show duplicates and save the record. – Helcyon Apr 27 '20 at 4:18
  • I tried by creating trigger but the thing is if i giving any company name its showing duplicates and saving the record can you review the above code. – Helcyon Apr 27 '20 at 5:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.