Merge Rules

Last published at: February 20th, 2025
Delete

The full set of Merge Rules as described below is available in our Premium and PDM editions. If you don't have a Premium or PDM subscription, feel free to apply for a trial.

In the Advanced edition, the available Merge Rules are 'Modified Date: Least Recent', 'Modified Date: Most Recent', 'Created Date: Least Recent', and 'Created Date: Most Recent'. These are described below as well.

When merging records within an object, Duplicate Check calls upon the Merge Rules to pick a master record, and to determine which field values should be stored in that master record. The Merge Rules also determine which master record and fields are pre-selected on the manual merge page, and the rules are used when executing an automated merge. 

Master Record Rule

The master record is the record that will be kept in Salesforce after merging. Out of a group of duplicate records, the master record is picked based on the master record rule. If the rule cannot determine a winning record, a fallback rule is used.

For example, you can decide that the master record is always the oldest record (Created date: Least Recent), the Record with the most fields populated, or the Record with the most attachments. Or use a value based record rule to set more advanced rules on text fields, so that the master record will always be the record that has a name that "starts with C",  or a level that is "equal to 1".

When deciding the master record based on a field based rule, another option is most common value. For example, decide that the master record has to be one of the records with the most often occurring value in the "email" field. Out of these records, the master record is then decided based on the fallback rule, in combination with "Fallback rule applies to" set to "Records selected by Initial Rule".

Let end-users change the master record

Decide if end-users working with the manual merge page are allowed to select a different master record than the one selected by the Master Record Rule. It could make sense to set a strict rule for defining the master record, which users are not able to bypass.
Toggle "Allow users to change the master record in a manual merge" to allow or disallow this.

Note that this applies only to setting the record that will be the master record. If disabled, users can still set certain field values on loser records to be copied over to the master record upon merge.

Field Rules

Field rules decide which field value will be kept in a master record. This is often the value from the master record, but it can also be a value from one of the losing records.
To always keep the master record value upon merge, simply leave the field rule for a certain field set to 'Master Record Rule'. 

For keeping a value from either the master or a loser record you have several options, depending on the field type. For example, take the longest value among the values on the master and losing records, or the most common value. For number fields, you can use a math rule such as average, sum, multiply or subtract to apply to all master and losing record values of a field, and record the outcome on the master record. 

Note that for date field rules such as Modified Date: Most Recent, the date of the record is considered, not the date of the particular field. So if between record A and record B the email field of record A was modified last, but after that a different field on record B is edited, the email address of record B will be retained when using field rule Modified Date: Most Recent.

Field Groups

Duplicate Check lets you group fields, after which you can assign the group a single field rule. This way the field values in a group are always taken from the same record, and kept together in a merge. So, for example, group the "email" and "email bounced reason" and make sure they always stay together. Or, decide to group a custom address field-set, which is then kept together always, even if one of the fields in the group is empty.

Retain all values of a field

There are a couple of options available for keeping the values of all records upon merging, instead of picking just one value to keep. 

Concatenate stores the values of the master and losing records together in the field on the master record.

Keep all values is similar, but stores the loser values in a second field.
For 'Keep all values', the values are appended to this second field, so any existing values are not overwritten. You can even store values from several fields in this extra field, although it is recommended to use separate extra fields for clarity and size. If the maximum character limit of the long text area is reached, the values are truncated at the end.

With multi-select picklists you can combine the values of the master and losing records, and add them all to the picklist on the master record.

For fields in a Field Group you can use Divide Values to divide all values from the master and loser records over the field group fields on the master record. Any additional field values are stored in a separate field.
For example, group all email fields and apply "Divide values". Now, in a merge operation, all email values from all records are kept and divided over the email fields in the master record. Any additional values are stored in the mapped long text area field.
Dividing only works for fields of the same field type.

Let blank fields be potential winners

Many fields and field groups have an option to "Allow Blank": allow a blank value. If enabled (ticked), a blank value can be chosen as a winning value to keep on the master record if the merge rule points to that value.
If disabled, and a merge rule initially points to an empty field, the rule is re-applied to decide which field value from the remaining records is best suited to be used in the master record.
Note that partially-filled addresses (e.g. addresses with a city and zip code filled in but no street) are considered to be not empty.

Fallback Rules

Some of the master record rules and field rules can't always pick a single winning record or value straight away, if several records or values can match the rule. For these cases, configure a fallback rule. The fallback rule will always result in only one winning record or value.
Then, decide to which records in the duplicate group the fallback rule should apply: only the records that meet the criteria of the initial rule, or all records from the duplicate group.

Accessing the Merge Rules

The merge rules are configured per Object, in DC Setup.

  1. Go to DC Setup.
  2. At left, click the Object to configure merge rules for.
  3. Go to tab Merge Rules.

Master Record Rule

Master Record Rule Description Fallback Rule
Modified Date: Least Recent The record modified least recently is the master record. No
Modified Date: Most Recent The record modified most recently is the master record. No
Created Date: Least Recent  The record created least recently is the master record. No
Created Date: Most Recent The record created most recently is the master record. No
Value Based

The master record is determined based on a field, and a given field value such as "equal to 1" or "starts with C".
Select a field, and then a field expression and field value.

Yes
Field Based

The master record is determined based on a field, and a field rule such as "shortest value" or "longest value".
Select a field, and then a field rule.

Yes
Record that has the most fields populated The record with the highest number of populated fields is the master record. Yes
Record with most attachments The record with the most attachments is the master record. Yes
Record connected to a Portal User The record that is linked to a Portal User is the master record.
Available for the Contact object.
Yes

Allow users to change the master record in a manual merge:

Toggle "Allow users to change the master record in a manual merge" to allow or disallow end-users working with the manual merge page to select a different master record than the one selected by the Master Record Rule.

Field Group Rules

Field Group Rule Description Fallback Rule
Master Record Rule The field group of the record selected by the master record rule is kept in the master record. No
Modified Date: Least Recent The field group of the record modified least recently is the group kept in the master record. No
Modified Date: Most Recent The field group of the record modified most recently is the group kept in the master record. No
Created Date: Least Recent The field group of the record created least recently is the group kept in the master record. No
Created Date: Most Recent The field group of the record created most recently is the group kept in the master record. No
Group with the most populated fields The field group with the most fields populated is the group kept in the master record. Yes
Keep All Values All loser records' field group values are stored in a second field. After selecting this option, configure the details in the modal.
Configure the settings for keeping all values in the Master RecordMerge rule for deciding the value in the Master Record

Select a rule that decides which value is kept in the field group of the master record.

Store additional values in Long Text Area

Select a long text area field for storing the field group values of the loser records.

Values to store

Unique Values - Will only store values in the mapped long text area field that differ from those kept in the master record.

All Values - Will store all values, regardless of whether they are duplicate to the values kept in the master record.

Delimiter

Choose a delimiter to separate the values in the long text area.

No
Divide Values

All values from the master and loser record field group are divided over the fields in the group in the master record. Any additional field values are stored in a separate long text area field. After selecting this option, configure the details in the modal.

Store additional values in Long Text Area

Select a long text area field for storing the additional field values that can't be stored in the fields in the field group due to a possible surplus.

Delimiter

Choose a delimiter to separate the values in the long text area.

No

Field Rules

Field Rule Description Fallback Rule
Master Record Rule  The value of the record selected in the master record rule is kept in the master record. No
Modified Date: Least Recent The value of the record modified least recently is kept in the master record. No
Modified Date: Most Recent The value of the record modified most recently is kept in the master record. No
Created Date: Least Recent The value of the record created least recently is kept in the master record. No
Created Date: Most Recent The value of the record created most recently is kept in the master record. No
Address that has the most fields populated

The address with the most populated fields is kept in the master record.

Available for Address compound fields.

Yes
Most Common Value

The value most common in the group of records is kept in the master record.

Please note that null values are not considered in this rule.

Available for field types: Text, Text Area, Email, Phone, URL, Picklist, Currency, Geolocation, Number, Checkbox, Date, Date & Time, Time.    

Yes
Concatenate Values Combines the values of the master and loser records in the same field. After selecting this option, configure the details in the modal.
Concatenate

Unique Values - The value in the loser record(s) is compared with the value in the master record. Only if the loser record(s) value differs from the master record is it concatenated in the field.

All Values - All values from the loser records are concatenated in the field, even if the value is duplicate.

Delimiter

Choose a delimiter to separate the values in the long text area.

Available for field types: Text, Text Area.

No
Keep All Values

Keep all values of a specific field by storing values from the loser records in a secondary long text area. After selecting this option, configure the details in the modal.

Merge rule for deciding the value in the Master Record

Pick a rule that decides which value is kept in the master record.

Store additional values in (Long) Text Area

Select a Long Text Area field for storing the additional values.

Values to store

Unique Values - Will only store values in the mapped long text area field that differ from the value kept in the master record.

All Values - Will store all values, regardless of whether they are duplicates to the value kept in the master record.

Delimiter

Choose a delimiter to separate the values in the long text area.

Available for field types: Text, Text Area, Email, Phone, URL, Picklist, Currency, Geolocation, Number, Address.

Yes
Shortest Value

The value with the smallest amount of characters will be kept in the master record. If there are two or more values with the same number of characters, the fallback rule will be applied.

Available for field types: Text, Text Area, Email, Phone, URL, Picklist. 

Yes
Longest Value

The value with the largest amount of characters will be kept in the master record. If there are two or more values with the same number of characters, the fallback rule will be applied.

Available for field types: Text, Text Area, Email, Phone, URL, Picklist. 

Yes
Highest in Picklist Order

The highest value in a picklist order selected in any of the records is kept in the master record.

Available for field types: Picklists.

No
Lowest in Picklist Order

The lowest value in a picklist order selected in any of the records is kept in the master record.

Available for field types: Picklists.

No
Minimum Value

The minimum value is kept in the master record.

Available for field types: Number, Percent, Currency.

No
Maximum Value

The maximum value is kept in the master record.

Available for field types: Number, Percent, Currency.

No
Sum

 Sums all values and stores the summed-up value in the master record.

Available for field types: Number, Currency.

No
Average

Takes the average of all values and stores the average value in the master record.

Available for field types: Number, Currency, Percent.

No
Multiply

Multiplies all values and stores the multiplied value in the master record.

Available for field types: Number, Currency.

No
Subtract

Sets all values from high to low and subtracts the values. The resulting value is stored in the master record.

E.g., If record A has a value of 12, Record B has a value of 23, and record C has a value of 40, the resulting value is 40 - 23 - 12 = 5.

Available for field types: Number, Currency.

No
True over False

Will keep a "true" value over a "false" value in the master record if it can be found in the records.

Available for field type: Checkbox.

No
False over True

Will keep a "false" value over a "true" value in the master record if it can be found in the records.

Available for field type: Checkbox.

No
Combine Values

Combines all values from a multi-select picklist that can be found in the records in the master record's picklist.

Available for field type: Multi-select Picklist.

No
Most Recent Value

Will keep the most recent value in the master record.

Available for field types: Date, Date & Time, Time, ID.

No
Least Recent Value

Will keep the least recent value in the master record.

Available for field type: Date, Date & Time, Time, ID.

No

Fallback Rules

Fallback Rule Description
Master Record Rule The value of the record selected in the master record rule is kept in the master record.
Modified Date: Least Recent The value of the record modified least recently is kept in the master record.
Modified Date: Most Recent The value of the record modified most recently is kept in the master record.
Created Date: Least Recent The value of the record created least recently is kept in the master record.
Created Date: Most Recent  The value of the record created most recently is kept in the master record.
Fallback Rule Applies To
Description
All Records The fallback rule will take all records in the duplicate group into account to determine the winner record or value.
Records selected by Initial Rule The fallback rule will only apply to records or values that meet the criteria of the initial rule.
Delete

If you want to create rules that are more complex than what you can configure in the Merge Rules, for example if you want to use fields of a different Object, have a look at our Merge Plugins. Use a Merge Plugin to execute custom Apex code before or right after a merge operation is done. Merge Plugins & Merge Rules can work together perfectly well.