Flow Name: Calculate Staff and Member Representation Counts¶
Last Updated: 2025-06-23 Source Code: Partnership_before_insert_update.flow-meta.xml
API Name: Partnership_before_insert_update Status: Obsolete Type: Custom Trigger: Before Partnership create/update when representation fields change
Business Purpose¶
Calculates and maintains counts of Member Representatives and Staff Liaisons on Partnership records by querying related Account Contact Relationships and Account Team Members. Referenced in PR-26845 for Partnership field calculations.
Process Flow¶
- Triggers before Partnership save when these fields change:
- Member_Representative_NAME__c, Staff_Liaisons__c
- Member_Representation_Count__c, Staff_Representation_Count__c
-
Calculate_count__c, Calculate_count_on_AT_delete__c, Calculate_count_on_ACR_delete__c
-
Member Representative Count:
- If Member_Representative_NAME__c exists:
- Gets Person Account for the representative
- Validates Account Contact Relationship exists with role "Member Representative"
- Counts all ACRs with role "Member Representative" for that Business Account
- Updates Member_Representation_Count__c
- If deleted (Calculate_count_on_ACR_delete__c changed): Decrements count by 1
-
If null: Sets count to 0
-
Staff Liaisons Count:
- If Staff_Liaisons__c exists:
- Gets Person Account for staff liaison
- Counts all Account Team Members for that account
- Updates Staff_Representation_Count__c
- If deleted (Calculate_count_on_AT_delete__c changed): Decrements count by 1
-
If null: Sets count to 0
-
Error Handling:
- Shows error if Member Representative account lacks proper ACR role
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: Before Save]) --> CheckMember{Member Rep<br/>Changed?}
CheckMember -->|Yes| GetMemberACR[Get ACRs for Member Rep]
CheckMember -->|No| CheckStaff{Staff Liaison<br/>Changed?}
GetMemberACR --> CountMember[Count Member Reps]
CountMember --> UpdateMember[Update Member Count]
UpdateMember --> CheckStaff
CheckStaff -->|Yes| GetTeam[Get Account Team Members]
CheckStaff -->|No| End([End])
GetTeam --> CountStaff[Count Staff Liaisons]
CountStaff --> UpdateStaff[Update Staff Count]
UpdateStaff --> End
style Start fill:#e1f5ff
style CheckMember fill:#fff4e1
style GetMemberACR fill:#e1ffe1
style CountMember fill:#ffe1e1
style UpdateMember fill:#ffe1e1
style CheckStaff fill:#fff4e1
style GetTeam fill:#e1ffe1
style CountStaff fill:#ffe1e1
style UpdateStaff fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Member Rep must have Account Contact Relationship with role "Member Representative"
- Staff count based on Account Team Members (all team members counted)
- Deletes decrement count by 1, creates/updates do full recount
- Validation error prevents save if Member Rep doesn't have correct role
- Counts can be triggered via Calculate_count__c checkbox changes
Dependencies¶
- Objects: Partnership__c, Account, AccountContactRelation, AccountTeamMember
- Fields:
- Member_Representative_NAME__c, Staff_Liaisons__c
- Member_Representation_Count__c, Staff_Representation_Count__c
- Calculate_count__c (trigger field)
- Calculate_count_on_AT_delete__c, Calculate_count_on_ACR_delete__c
- Roles_Includes_Member_Representative__c (formula field on ACR)
- Related Flows: Count_the_Staff_and_Member_Representation (replaced this flow)
Changes¶
PR-26845: Partnership fields - This flow was created to calculate Staff representative count and Member Representation count fields on Partnership object.
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- FLOW IS OBSOLETE: This flow is marked as Obsolete - should NOT be activated
- Complex Before-Save Logic: Heavy query logic in before-save context could cause timeout issues
- User-Facing Error: Error message appears without guidance on how to fix
HIGH - Address Soon After Go-Live¶
- Not Applicable: Flow is Obsolete
MEDIUM - Future Enhancement¶
- Not Applicable: Flow is Obsolete
LOW - Monitor¶
- Not Applicable: Flow is Obsolete
Maintenance Notes¶
Complexity: Very High - Multiple lookups, loops, and decision trees in before-save context Status: OBSOLETE - Do not activate this flow Replacement: Replaced by Count_the_Staff_and_Member_Representation autolaunched flow called from Update_Partnership_on_Create_Update and Update_Partnership_on_Delete flows Performance Issue: Before-save flows with extensive queries are problematic - replacement architecture is better PR-26845: Original implementation for Partnership representation counting Delete Recommendation: Consider removing this obsolete flow after confirming replacement flows are stable