How to create a Master selection custom rule - Advanced

Create custom formula-based scoring to define complex master record selection rules in Delpha. Learn to sort duplicates based on business logic in Salesforce.

How to Use a Custom Formula for Complex Master Record Selection

In some cases, selecting a master record based on a simple value comparison (like highest number or checkbox = true) isn’t enough. When your business logic is more advanced, the best approach is to create a custom formula field that scores each record based on multiple conditions.

This score is then used to sort the duplicate pair and select the master record.

When to Use a Formula-Based Master Rule

Use a formula when:

  • You need to prioritize based on a combination of picklists, metrics, and dates

  • You want to handle tie-breaker logic across several layers

  • Your logic changes based on status, recency, or business value

Step-by-Step Setup

1. Create a Custom Formula Field

  • Object: Account, Contact, or Lead (where duplicates occur)

  • Field Type: Formula

  • Return Type: Number

  • Example API Name: MyDuplicateMasterRecordScore__c

2. Add Your Logic in the Formula Field

Here’s a complete example based on business rules:

salesforceCopyEditCASE(
   Status__c,
   "Customer", 10000,      /* Rule 1: Always prioritize Customer */
   "Prospect", 5000,       /* Rule 3: Prospect over Target */
   "Target", 1000,
   0
) +
IF(
   AND(Status__c = "Customer", NOT(ISBLANK(Number_of_Opportunities__c))),
   Number_of_Opportunities__c * 10,  /* Rule 2: More Opps wins among Customers */
   0
) +
IF(
   AND(Status__c = "Prospect", Last_Touchpoint_Date__c < TODAY() - 180),
   -4000,  /* Penalize cold Prospects */
   0
) +
(100000000 - CreatedDate) /* Rule 4: Prefer oldest if all else equal */

This formula returns a numeric score. The record with the highest score becomes the master during the merge.

3. Use It in Delpha Duplicate Settings

In Delpha Setup → Duplicate Settings, set the Master Rule to:

MyDuplicateMasterRecordScore__c DESC

What This Covers

  • Rule 1: Always select Customer as master

  • Rule 2: Among Customers, prioritize by # of Opportunities

  • Rule 3: Prefer Prospect over Target, unless the Prospect is outdated

  • Rule 4: Use Created Date as fallback

Last updated

Was this helpful?