Skip to content

Flow Name: On update Person Account Email Address

Last Updated: 2025-06-10 Source Code: On_update_Person_Account_Email_Address.flow-meta.xml

API Name: On_update_Person_Account_Email_Address Status: Active Type: Custom Trigger: Record Update (Account) - Before Save

Business Purpose

This flow manages email address history and prevents duplicate emails when a Person Account's primary email address is changed. It implements a cascading email system where the previous primary email becomes secondary, and the previous secondary becomes tertiary, while also validating that the new email doesn't already exist in the system.

Process Flow

  1. Trigger Activation: Fires when Person Account PersonEmail changes (excludes anonymized accounts)
  2. Duplicate Email Check: Searches for existing accounts with the new email in any email field:
  3. PersonEmail, Email_Secondary__c, or Email_Tertiary__c
  4. Excludes the current account from search
  5. Email Validation Decision:
  6. If duplicate found → Display error message and prevent save
  7. If no duplicate → Continue with email cascading logic
  8. Email Cascading Logic:
  9. If Email_Secondary__c has value → Move to tertiaryEmail variable
  10. Move previous PersonEmail to secondaryEmail variable
  11. Update account with new email hierarchy:
    • Email_Secondary__c = previous PersonEmail
    • Email_Tertiary__c = previous Email_Secondary__c
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: Record Update (Account) - Before Save]) --> Check{Entry Criteria<br/>Met?}

    Check -->|No| End([End])
    Check -->|Yes| Process[Execute Business Logic]

    Process --> Update[Update Records]
    Update --> End

    style Start fill:#e1f5ff
    style Check fill:#fff4e1
    style Process fill:#e1ffe1
    style Update fill:#ffe1e1
    style End fill:#e1f5ff

Key Business Rules

  • Prevents duplicate emails across all three email fields system-wide
  • Implements email history preservation through cascading (Primary → Secondary → Tertiary)
  • Previous secondary email is overwritten when cascading to tertiary
  • Excludes anonymized accounts (Anonymized__c ≠ true) from processing
  • Validation occurs before save to prevent bad data entry
  • Error message clearly explains the duplicate email restriction

Dependencies

  • Objects: Account (Person Account functionality)
  • Custom Fields:
  • Email_Secondary__c
  • Email_Tertiary__c
  • Anonymized__c
  • PersonId__c (used in duplicate detection)
  • Standard Fields: PersonEmail
  • Variables: secondaryEmail, tertiaryEmail (string variables for processing)

Changes

  • PR-31095: Implemented the email cascading logic described in the flow description

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • Data Loss Risk: Previous Email_Tertiary__c value is permanently lost when cascading occurs
  • Inconsistent Duplicate Check: Uses PersonId__c field in search but logic suggests it should use Account Id

HIGH - Address Soon After Go-Live

  • User Experience: Error message stops the save process but doesn't indicate which account has the conflicting email
  • Email Validation: No validation that email addresses are properly formatted
  • Case Sensitivity: Email comparison may be case-sensitive, allowing duplicates with different casing

MEDIUM - Future Enhancement

  • Email History Limit: Consider whether three email addresses are sufficient for business needs
  • Archive Mechanism: Implement proper email history archiving instead of overwriting tertiary email
  • Notification System: Consider notifying users when their email addresses are moved to secondary/tertiary

LOW - Monitor

  • Performance: Email duplicate searches across all accounts could impact performance with large datasets
  • Edge Cases: Monitor for scenarios where bulk email updates might cause performance issues
  • Data Quality: Track how often email cascading occurs to understand user behavior patterns

Maintenance Notes

This flow implements critical data integrity controls for email management. The cascading logic prevents data loss of recent email addresses but permanently loses the oldest tertiary email. The duplicate prevention is essential for user account management and communication systems. Recommend monthly review of email change patterns and validation that the cascading logic meets business requirements. Consider implementing comprehensive email history tracking if the current three-email limit becomes insufficient.