Flow Name: Account Team Member: to calculate Partnership fields (After Insert)¶
Last Updated: 2024-11-14 Source Code: Account_Team_Member_After_Insert.flow-meta.xml
API Name: Account_Team_Member_After_Insert Status: Active Type: Custom Trigger: After insert of AccountTeamMember records
Business Purpose¶
This flow maintains data integrity on Partnership records by triggering recalculation of partnership representation counts when new Account Team Members are added. It ensures that Partnership objects accurately reflect current staff liaisons and member representation statistics by toggling calculation flags.
Process Flow¶
- Get Partnerships: Queries Partnership__c records where Staff_Liaisons__c equals the new Account Team Member's AccountId
- Check Partnerships Exist: Verifies partnerships are found before proceeding
- Loop Through Partnerships: Iterates through each related partnership record
- Toggle Calculation Flag: For each partnership, checks the current value of Calculate_count__c field and flips it (false becomes true, true becomes false)
- Build Update List: Adds modified partnership records to a collection for bulk update
- Update Partnerships: Performs bulk update of all modified partnership records
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: AccountTeamMember<br/>After Insert Trigger]) --> GetPartner[Get Partnership Records<br/>where Staff_Liaisons__c<br/>= AccountId]
GetPartner --> HasPartner{Partnerships<br/>Found?}
HasPartner -->|No| End([End])
HasPartner -->|Yes| Loop[Loop Through Each<br/>Partnership Record]
Loop --> Toggle[Toggle Calculate_count__c:<br/>• If TRUE → Set FALSE<br/>• If FALSE → Set TRUE]
Toggle --> AddToCollection[Add Modified Partnership<br/>to Update Collection]
AddToCollection --> MoreRecords{More<br/>Partnerships?}
MoreRecords -->|Yes| Loop
MoreRecords -->|No| BulkUpdate[Bulk Update All<br/>Partnership Records]
BulkUpdate --> End
style Start fill:#e1f5ff
style GetPartner fill:#f0e1ff
style HasPartner fill:#fff4e1
style Loop fill:#e1ffe1
style Toggle fill:#ffe1e1
style AddToCollection fill:#e1ffe1
style MoreRecords fill:#fff4e1
style BulkUpdate fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Only partnerships where Staff_Liaisons__c matches the new team member's AccountId are affected
- The Calculate_count__c field is toggled to trigger downstream calculations
- Updates are performed in bulk to maintain efficiency
- Process only executes if partnerships exist for the account
Dependencies¶
- Partnership__c custom object and its Calculate_count__c field
- AccountTeamMember standard object
- Related flow "Count the Staff and Member Representation" for actual count calculations
- Account object (referenced through AccountTeamMember.AccountId)
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- Validation Required: No error handling if Partnership updates fail, which could leave data in inconsistent state
- Bulk Limits: No governor limit handling for large numbers of partnerships per account
HIGH - Address Soon After Go-Live¶
- Performance Optimization: Each partnership update triggers additional flows, potentially causing performance issues with many partnerships
- Duplicate Processing: No check to prevent multiple executions for the same partnership
MEDIUM - Future Enhancement¶
- Logic Clarity: The toggle mechanism (flip true/false) is not intuitive and could be simplified
- Conditional Processing: Could check if calculation is actually needed before updating
LOW - Monitor¶
- Field Naming: Uses Calculate_count__c vs Calculate_count_on_AT_delete__c in delete flow - inconsistent naming
- Variable Naming: Generic variable names could be more descriptive
Maintenance Notes¶
Complexity: Medium - Straightforward logic but depends on external calculation flows. Review quarterly as part of partnership data integrity checks. Monitor for performance impacts when accounts have many partnerships. Note the slight field name difference from the delete counterpart flow.