Flow Name: Account Contact Relation: to calculate Partnership fields (After Insert)¶
Last Updated: 2025-09-08 Source Code: Account_Contact_Relation_After_Insert.flow-meta.xml
API Name: Account_Contact_Relation_After_Insert Status: Active Type: Custom Trigger: AccountContactRelation creation/update (after save) when key fields change
Business Purpose¶
Calculates and maintains partnership field counts by updating Partnership records when Account Contact Relationships change, specifically tracking staff representatives and member representatives for partnership management.
Process Flow¶
- Triggers on AccountContactRelation create/update when ContactId, Roles, or AccountId changes
- Retrieves all AccountContactRelations for the account with Member Representative role
- Collects Contact IDs from these relationships
- Finds corresponding Person Accounts using the Contact IDs
- Queries Partnership records where Member_Representative_NAME__c matches found accounts
- Toggles Calculate_count__c field on partnerships to trigger recalculation
- Updates Partnership records to refresh counts
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: AccountContactRelation<br/>Create/Update After Save]) --> EntryCheck{Key Field Changed?<br/>ContactId OR<br/>Roles OR<br/>AccountId}
EntryCheck -->|No| End([End])
EntryCheck -->|Yes| GetACRs[Get All AccountContactRelations<br/>for Account with<br/>Member Representative Role]
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__c Field<br/>to trigger recalculation]
Toggle --> UpdatePartnerships[Update Partnership Records]
UpdatePartnerships --> End([End])
style Start fill:#e1f5ff
style EntryCheck fill:#fff4e1
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¶
- Only processes relations with "Member Representative" role (Roles_Includes_Member_Representative__c = true)
- Toggles boolean flag to trigger separate calculation logic
- Uses complex relationship traversal: AccountContactRelation → Contact → Person Account → Partnership
- Processes multiple partnerships that may be affected by single relationship change
Dependencies¶
- AccountContactRelation object with Roles_Includes_Member_Representative__c field
- Partnership__c custom object with Calculate_count__c and Member_Representative_NAME__c fields
- Person Account setup with proper Contact relationships
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- No error handling for failed lookups or updates
- Risk of infinite loops if Partnership updates trigger additional flows
- No validation that Partnership records exist before update
HIGH - Address Soon After Go-Live¶
- Complex query chain could impact performance with large datasets
- Boolean toggle pattern is fragile and hard to debug
- Missing null checks on relationship traversals
MEDIUM - Future Enhancement¶
- Replace toggle pattern with direct calculation for better maintainability
- Add logging for partnership count changes
- Consolidate with similar flows handling partnership calculations
LOW - Monitor¶
- Monitor query limits with high-volume relationship changes
- Performance degradation with deep object relationships
Maintenance Notes¶
High complexity flow with intricate object relationships. Requires careful testing when modifying Partnership or AccountContactRelation objects. Consider refactoring toggle pattern for better reliability.