Flow Name: Update Partnership on Delete¶
Last Updated: 2025-04-29 Source Code: Update_Partnership_on_Delete.flow-meta.xml
API Name: Update_Partnership_on_Delete Status: Active Type: Custom Trigger: Before AANP_Representation__c delete when Role is Member Representative or Staff Liaisons
Business Purpose¶
Maintains accurate representation counts on Partnership records by triggering recalculation when Member Representative or Staff Liaison relationships are deleted, ensuring counts are decremented appropriately.
Process Flow¶
- Triggers before AANP_Representation__c record is deleted
- Filters for Role__c = "Member Representative" OR "Staff Liaisons"
- Calls subflow "Count_the_Staff_and_Member_Representation" with parameters:
- aanPRepresentationId: Current record ID (being deleted)
- partnershipId: Partnership__c from current record
- eventAction: "Delete"
- Subflow performs decrement logic and updates Partnership counts
- After subflow completes, record is deleted
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: AANP Representation<br/>Delete Before Delete]) --> Filter{Role is<br/>Member Representative<br/>OR Staff Liaisons?}
Filter -->|Yes| Subflow[Call Subflow:<br/>Count_the_Staff_and_Member_Representation<br/>Pass: aanPRepresentationId, partnershipId, eventAction='Delete']
Filter -->|No| End([End])
Subflow --> End
style Start fill:#e1f5ff
style Filter fill:#fff4e1
style Subflow fill:#f0e1ff
style End fill:#e1f5ff
Key Business Rules¶
- Only processes two role types: "Member Representative" and "Staff Liaisons"
- Executes before delete to access record data before removal
- Passes "Delete" action to subflow for decrement logic
- No direct DML - delegates all updates to subflow
- Subflow decrements count by 1 rather than recounting
Dependencies¶
- Objects: AANP_Representation__c, Partnership__c
- Fields: Role__c, Partnership__c
- Subflows: Count_the_Staff_and_Member_Representation (core calculation logic)
- Related Flows: Update_Partnership_on_Create_Update (handles create/update events)
Changes¶
No Pull Request references found in metadata.
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- No Error Handling: If subflow fails during delete, record may be deleted but count not updated
- Missing Validation: Doesn't verify Partnership__c exists before calling subflow
HIGH - Address Soon After Go-Live¶
- Count Drift Risk: Delete using decrement rather than recount could lead to inaccurate totals over time
- User Experience: Before-delete triggers can't prevent delete but can slow it down
MEDIUM - Future Enhancement¶
- Error Logging: Add fault connector to log subflow failures during delete
- Consistency Check: Periodic job to verify counts match actual records
- Prevent Orphans: Consider validation to prevent deleting last representative
LOW - Monitor¶
- Subflow Execution: Monitor Count_the_Staff_and_Member_Representation for failures
- Data Accuracy: Watch for Partnerships with negative or incorrect counts
- Delete Volumes: Monitor for bulk deletes that could cause performance issues
Maintenance Notes¶
Complexity: Low - Simple trigger orchestration calling subflow Review Schedule: Review when representation or partnership logic changes Subflow Dependency: All business logic is in Count_the_Staff_and_Member_Representation Paired Flow: Works with Update_Partnership_on_Create_Update for complete lifecycle management Before-Delete Context: Necessary to access record data before deletion Count Drift Risk: Decrement approach in subflow could accumulate errors - periodic reconciliation recommended