Skip to content

Flow Name: Account Contact Relationship after delete

Last Updated: 2025-09-08 Source Code: Account_Contact_Relationship_after_delete.flow-meta.xml

API Name: Account_Contact_Relationship_after_delete Status: Active Type: Custom Trigger: AccountContactRelation deletion (before delete)

Business Purpose

Maintains data integrity by updating Partnership records and Account Company Administrator flags when Account Contact Relationships are deleted, ensuring accurate representation counts and user permissions.

Process Flow

  1. Triggers when AccountContactRelation is being deleted
  2. Company Admin Logic:
  3. Retrieves remaining AccountContactRelations for the same contact
  4. Checks if any remaining relationships have "Company Administrator" role
  5. Updates Account Is_Company_Admin__c field based on remaining admin relationships
  6. Partnership Count Logic:
  7. Gets AccountContactRelations with Member Representative role for the account
  8. Finds corresponding Person Accounts
  9. Identifies affected Partnership records
  10. Toggles Calculate_count_on_ACR_delete__c field to trigger recalculation
  11. Updates Partnership records
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: AccountContactRelation<br/>Before Delete Trigger]) --> GetRemaining[Get Remaining<br/>AccountContactRelations<br/>for Contact]

    GetRemaining --> AdminCheck{Any Remaining<br/>Relationships with<br/>Company Admin Role?}

    AdminCheck -->|Yes| SetAdminTrue[Set Account<br/>Is_Company_Admin__c = TRUE]
    AdminCheck -->|No| SetAdminFalse[Set Account<br/>Is_Company_Admin__c = FALSE]

    SetAdminTrue --> GetACRs[Get AccountContactRelations<br/>with Member Representative Role<br/>for Account]
    SetAdminFalse --> GetACRs

    GetACRs --> CollectContacts[Collect Contact IDs<br/>from AccountContactRelations]

    CollectContacts --> FindAccounts[Find Person Accounts<br/>where PersonContactId<br/>matches Contact IDs]

    FindAccounts --> GetPartnerships[Get Partnership Records<br/>where Member_Representative_NAME__c<br/>matches Person Accounts]

    GetPartnerships --> Toggle[Toggle Calculate_count_on_ACR_delete__c<br/>to trigger recalculation]

    Toggle --> UpdatePartnerships[Update Partnership Records]

    UpdatePartnerships --> End([End])

    style Start fill:#e1f5ff
    style GetRemaining fill:#f0e1ff
    style AdminCheck fill:#fff4e1
    style SetAdminTrue fill:#ffe1e1
    style SetAdminFalse fill:#ffe1e1
    style GetACRs fill:#f0e1ff
    style CollectContacts fill:#e1ffe1
    style FindAccounts fill:#f0e1ff
    style GetPartnerships fill:#f0e1ff
    style Toggle fill:#ffe1e1
    style UpdatePartnerships fill:#ffe1e1
    style End fill:#e1f5ff

Key Business Rules

  • Processes Company Administrator status before partnership calculations
  • Only affects partnerships with Member Representative roles
  • Uses toggle fields to trigger external calculation processes
  • Maintains referential integrity across complex object relationships

Dependencies

  • AccountContactRelation with roles including "Company Administrator" and Member Representative
  • Account object with Is_Company_Admin__c field
  • Partnership__c with Calculate_count_on_ACR_delete__c and Member_Representative_NAME__c fields
  • Person Account configuration

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • No error handling for cascading updates
  • Risk of data inconsistency if flow fails partway through
  • Boolean toggle pattern could cause issues with concurrent deletions

HIGH - Address Soon After Go-Live

  • Complex logic combining two different business processes in one flow
  • Missing validation that Company Admin detection works correctly
  • No safeguards against orphaned Partnership records

MEDIUM - Future Enhancement

  • Split into separate flows for Company Admin and Partnership logic
  • Add comprehensive error handling and rollback mechanisms
  • Implement proper audit trail for admin status changes

LOW - Monitor

  • Performance with bulk deletions
  • Potential conflicts with other flows modifying the same records

Maintenance Notes

Extremely complex flow handling two distinct business processes. High risk for maintenance. Recommend splitting into focused flows and improving error handling before production deployment.