Flow Name: [AANP][RT] Account: Assign Election Region¶
Last Updated: 2025-08-06 Source Code: AANP_RT_Account_Assign_Election_Region.flow-meta.xml
API Name: AANP_RT_Account_Assign_Election_Region Status: Active Type: Custom Trigger: Record Update (Account) - Before Save
Business Purpose¶
This flow automatically assigns election regions to AANP member accounts based on their mailing state. It ensures members are properly categorized by geographic region for voting purposes, while clearing regions for non-members or accounts without valid state mappings.
Process Flow¶
- Trigger Check: Activates when a Person Account record is updated and:
- Is a Person Account
- Has PersonMailingCountry = "United States"
- PersonMailingStateCode OR Is_Member__c field changes
- Region Mapping Lookup: Queries Election_Region__mdt custom metadata for the account's mailing state code
- Mapping Validation Decision:
- If no mapping found → Clear AANP_Election_Region__c field
- If mapping found → Proceed to member status check
- Member Status Decision:
- If Is_Member__c = false → Clear AANP_Election_Region__c field
- If Is_Member__c = true → Update AANP_Election_Region__c with mapped region
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: Account Update<br/>Before Save Trigger]) --> EntryCheck{Entry Criteria:<br/>Person Account AND<br/>US Mailing Address AND<br/>State or Member Status Changed?}
EntryCheck -->|No| End([End])
EntryCheck -->|Yes| Lookup[Get Election Region Mapping<br/>from Election_Region__mdt<br/>by PersonMailingStateCode]
Lookup --> MappingCheck{Mapping Found?}
MappingCheck -->|No| ClearNoMapping[Set AANP_Election_Region__c<br/>to Blank]
MappingCheck -->|Yes| MemberCheck{Is Member?<br/>Is_Member__c = TRUE}
MemberCheck -->|No| ClearNonMember[Set AANP_Election_Region__c<br/>to Blank]
MemberCheck -->|Yes| UpdateRegion[Set AANP_Election_Region__c<br/>= Mapped Region]
ClearNoMapping --> End
ClearNonMember --> End
UpdateRegion --> End
style Start fill:#e1f5ff
style EntryCheck fill:#fff4e1
style Lookup fill:#f0e1ff
style MappingCheck fill:#fff4e1
style MemberCheck fill:#fff4e1
style ClearNoMapping fill:#ffe1e1
style ClearNonMember fill:#ffe1e1
style UpdateRegion fill:#e1ffe1
style End fill:#e1f5ff
Key Business Rules¶
- Only applies to Person Accounts in the United States
- Election regions are only maintained for active members (Is_Member__c = true)
- Non-members have their election region field blanked out
- Region assignment depends on custom metadata type Election_Region__mdt
- State code mapping uses PersonMailingStateCode field
Dependencies¶
- Objects: Account (Person Account record type)
- Custom Fields:
- Is_Member__c (Account)
- AANP_Election_Region__c (Account)
- Custom Metadata: Election_Region__mdt with State_Code__c and Region__c fields
- Standard Fields: PersonMailingStateCode, PersonMailingCountry, IsPersonAccount
Changes¶
No specific pull request references noted in the flow metadata.
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- None identified
HIGH - Address Soon After Go-Live¶
- Missing Error Handling: No fault paths or error handling for failed metadata lookups or record updates
- Data Validation: No validation to ensure Election_Region__mdt records exist for all US states
MEDIUM - Future Enhancement¶
- Hardcoded Values: "United States" country value is hardcoded - should be configurable for international expansion
- Metadata Dependency: Flow relies on Election_Region__mdt being properly maintained
LOW - Monitor¶
- Performance: Metadata lookup on every qualifying account update could impact performance with high volume updates
- Edge Cases: Behavior undefined if multiple election regions exist for same state code
Maintenance Notes¶
This flow has moderate complexity with multiple decision points. The custom metadata dependency requires ongoing maintenance to ensure state mappings remain current. Recommend monthly review of Election_Region__mdt records and quarterly validation of flow logic.