# Related Object Rules

### Overview

When merging two records (e.g., Contact A and Contact B), Salesforce automatically re-parents all child records to the surviving Master Record. This can create a new problem: Child Duplicates.

* *Scenario:* Contact A has an Opportunity named "Q3 Deal." Contact B *also* has a duplicate Opportunity named "Q3 Deal."
* *Result without rules:* The final merged Contact will have *two* identical "Q3 Deal" Opportunities in its related list.
* *Solution:* Related Object Rules allow you to detect and merge these child duplicates automatically during the parent merge process.

### How to Configure Related Object Rules

1. Access the Section: In Merge Settings, expand Related Object Rules.
2. Add New Rule: Click the New button.
3. Select the Related Object: Choose the child object you want to manage (e.g., `Opportunity`, `Case`, or a Custom Object).
4. Define the Relationship:
   * Related Object Field: Select the lookup field that connects the child to the parent (e.g., `AccountId` or `ContactId`).
5. Define Deduplication Logic:
   * Duplicate Group Expression: This works like a unique key. Select the field(s) that identify a duplicate *within the context of this parent*.
     * *Example:* For Opportunities, you might select `Name`. If two Opportunities have the exact same `Name` on the same Account, Delpha treats them as duplicates.
     * *Note:* This uses strict exact matching (full match, no fuzzy logic).
6. Select the "Winner" Strategy:
   * Selection Criteria: Decide which of the duplicate child records should be kept.
     * `Keep Based on Newest Record`: Retains the most recently created item.
     * `Keep based On Oldest Record`: Retains the original item.
     * `Keep Based on Latest Modified Record`: Retains the one with the most recent updates.
     * `Keep Master Record Items`: Always prioritizes the child record that was already owned by the Master parent record.

### Example Configuration: Deduplicating Opportunities

To ensure you don't end up with duplicate opportunities after merging Accounts:

* Related Object: `Opportunity`.
* Duplicate Group Expression: `Name` (and optionally `CloseDate`).
* Selection Criteria: `Keep Based on Latest Modified Record`.
* Result: If both Accounts have an opportunity named "Big Deal," only the one updated most recently is kept. The other is deleted/merged.

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.delpha.io/delpha-for-salesforce/use-cases-setup/duplicate/duplicate-merge/related-object-rules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
