From 8e03bcff515f0d477191c8d42928290240e58c67 Mon Sep 17 00:00:00 2001 From: StarleyFlynn Date: Mon, 2 Jul 2018 10:41:20 -0600 Subject: [PATCH 1/3] Update INT_InteractionProcessor.cls --- src/classes/INT_InteractionProcessor.cls | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/classes/INT_InteractionProcessor.cls b/src/classes/INT_InteractionProcessor.cls index 898ae8e..e9bb7b2 100755 --- a/src/classes/INT_InteractionProcessor.cls +++ b/src/classes/INT_InteractionProcessor.cls @@ -445,7 +445,7 @@ public class INT_InteractionProcessor { for (Datacloud.MatchResult matchResult : dupError.getDuplicateResult().getMatchResults()) { Contact matchedContact; - + if (matchResult.getEntityType() == 'Contact'){ for (Datacloud.MatchRecord match : matchResult.getMatchRecords()) { // We want to use the oldest matched record, it will be the source Contact. Contact compareContact = (Contact) match.getRecord(); @@ -454,6 +454,7 @@ public class INT_InteractionProcessor { matchedContact = compareContact; } } + } // Build new Lead convert with matching records. if (matchedContact != null) { // NPE handling @@ -575,4 +576,4 @@ public class INT_InteractionProcessor { } } } -} \ No newline at end of file +} From 5a908558a4c1147afd00afa4b814166e171b868c Mon Sep 17 00:00:00 2001 From: StarleyFlynn Date: Wed, 11 Jul 2018 16:13:58 -0600 Subject: [PATCH 2/3] Update INT_InteractionProcessor.cls --- src/classes/INT_InteractionProcessor.cls | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/classes/INT_InteractionProcessor.cls b/src/classes/INT_InteractionProcessor.cls index e9bb7b2..f9fe50b 100755 --- a/src/classes/INT_InteractionProcessor.cls +++ b/src/classes/INT_InteractionProcessor.cls @@ -354,6 +354,7 @@ public class INT_InteractionProcessor { Database.DuplicateError dupErrorError = (Database.DuplicateError) error; for (Datacloud.MatchResult matchResult : dupErrorError.getDuplicateResult().getMatchResults()) { + if (matchResult.getEntityType() == 'Lead'){ for (Datacloud.MatchRecord match : matchResult.getMatchRecords()) { // Grab matched record to use instead of the new one. interaction.Lead__c = match.getRecord().Id; @@ -371,6 +372,7 @@ public class INT_InteractionProcessor { } } } + } } else { // Catch-all for all other errors interaction.Audit_Reason__c += ' Reason: Error during Lead insert - ' + error.getMessage() + '.'; System.debug('Error during Lead insert - ' + error.getMessage() + '.'); From 712eba7536387eae686f4f4d13878fc400f040b8 Mon Sep 17 00:00:00 2001 From: StarleyFlynn Date: Wed, 24 Oct 2018 17:37:19 -0600 Subject: [PATCH 3/3] Update INT_InteractionProcessor.cls Setting DMLOptions to allowSave allows duplicate matching rules that alert rather than block to save results. This allows the standard duplicate account rule to be bypassed within the interaction context, but still warn users that they may be creating duplicate accounts when interacting with the UI. --- src/classes/INT_InteractionProcessor.cls | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/classes/INT_InteractionProcessor.cls b/src/classes/INT_InteractionProcessor.cls index f9fe50b..3ce87af 100755 --- a/src/classes/INT_InteractionProcessor.cls +++ b/src/classes/INT_InteractionProcessor.cls @@ -412,7 +412,10 @@ public class INT_InteractionProcessor { */ private List convertLeads(List leadsToConvert) { List leadsToReconvert = new List(); - Database.LeadConvertResult[] leadConvertResults = Database.convertLead(leadsToConvert, false); // Convert Leads + //Setting DMLOptions to allowSave allows duplicate matching rules that alert rather than block to save results. This allows the standard duplicate account rule to be bypassed. + Database.DMLOptions dml = new Database.DMLOptions(); + dml.DuplicateRuleHeader.AllowSave = true; + Database.LeadConvertResult[] leadConvertResults = Database.convertLead(leadsToConvert, dml); // Convert Leads for (Database.LeadConvertResult lcr : leadConvertResults) { Interaction__c interaction = (leadIdToInteractionMap.containsKey(lcr.getLeadId())) ? leadIdToInteractionMap.get(lcr.getLeadId()) : null;