Flow Name: Country Buyer Group Assignment¶
Last Updated: 2025-08-03 Source Code: Country_Buyer_Group_Assignment.flow-meta.xml
API Name: Country_Buyer_Group_Assignment Status: Active Type: Custom Trigger: Auto-launched Flow (invoked by other processes)
Business Purpose¶
This flow automatically assigns person accounts to appropriate international buyer groups based on their billing country codes. It manages three-tier international pricing by categorizing customers into "International Tier 1", "International Tier 2", and "International Tier 3" buyer groups. Additionally, it maintains ContactPointAddress records to support commerce operations.
Process Flow¶
- Buyer Group Retrieval: Loads all three international tier buyer groups:
- International Tier 1, 2, and 3 buyer groups
- Adds group IDs to a collection for processing
- Address Management:
- Retrieves existing ContactPointAddress with AddressType="Shipping" and IsDefault=true
- Either updates existing address or creates new one with account's PersonMailingAddress data
- Existing Group Cleanup:
- Identifies current country-based buyer group assignments
- Deletes existing assignments to prevent duplicates
- Country Classification: Sequentially checks country metadata types:
- Countries_Group_1__mdt: For International Tier 1 countries
- Countries_Group_2__mdt: For International Tier 2 countries
- Countries_Group_3__mdt: For International Tier 3 countries
- Group Assignment: Creates BuyerGroupMember records based on country classification
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: Auto-launched Flow]) --> GetGroups[Get 3 International<br/>Buyer Groups:<br/>Tier 1, 2, 3]
GetGroups --> CheckAddr{Existing Default<br/>ContactPointAddress?}
CheckAddr -->|Yes| UpdateAddr[Update Existing Address<br/>with PersonMailingAddress]
CheckAddr -->|No| CreateAddr[Create New ContactPointAddress<br/>from PersonMailingAddress]
UpdateAddr --> GetCurrent[Get Current Country-based<br/>Buyer Group Memberships]
CreateAddr --> GetCurrent
GetCurrent --> Delete[Delete Existing<br/>Country Group Memberships]
Delete --> CheckTier1[Check Countries_Group_1__mdt<br/>for PersonMailingCountryCode]
CheckTier1 --> Tier1{Found in<br/>Tier 1?}
Tier1 -->|Yes| AssignTier1[Create BuyerGroupMember<br/>for Tier 1]
Tier1 -->|No| CheckTier2[Check Countries_Group_2__mdt]
CheckTier2 --> Tier2{Found in<br/>Tier 2?}
Tier2 -->|Yes| AssignTier2[Create BuyerGroupMember<br/>for Tier 2]
Tier2 -->|No| CheckTier3[Check Countries_Group_3__mdt]
CheckTier3 --> Tier3{Found in<br/>Tier 3?}
Tier3 -->|Yes| AssignTier3[Create BuyerGroupMember<br/>for Tier 3]
Tier3 -->|No| End([End])
AssignTier1 --> End
AssignTier2 --> End
AssignTier3 --> End
style Start fill:#e1f5ff
style GetGroups fill:#f0e1ff
style CheckAddr fill:#fff4e1
style UpdateAddr fill:#ffe1e1
style CreateAddr fill:#ffe1e1
style GetCurrent fill:#f0e1ff
style Delete fill:#ffe1e1
style CheckTier1 fill:#f0e1ff
style Tier1 fill:#fff4e1
style CheckTier2 fill:#f0e1ff
style Tier2 fill:#fff4e1
style CheckTier3 fill:#f0e1ff
style Tier3 fill:#fff4e1
style AssignTier1 fill:#ffe1e1
style AssignTier2 fill:#ffe1e1
style AssignTier3 fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Only processes Person Accounts (IsPersonAccount = true)
- Uses PersonMailingCountryCode to determine tier assignment
- Removes existing country-based buyer group memberships before assigning new ones
- ContactPointAddress creation/update uses person account mailing address fields
- Country tier assignment is mutually exclusive (account belongs to only one tier)
- Uses isBuyer check to ensure account is eligible for buyer groups
Dependencies¶
- Objects:
- Account (Person Account records)
- BuyerGroup, BuyerGroupMember (Commerce Cloud objects)
- ContactPointAddress (Commerce Cloud address management)
- Custom Metadata Types:
- Countries_Group_1__mdt, Countries_Group_2__mdt, Countries_Group_3__mdt
- Each with ISOCode__c field for country matching
- Custom Fields: Various address and buyer-related fields on Account
- Relationships: Account to ContactPointAddress via ParentId
Changes¶
- Added isBuyer Check: Enhanced to ensure only buyer accounts are processed
- PR-31175: Added logic to update existing ContactPointAddress or create new one based on PersonMailingAddress changes
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- No Error Handling: Extensive flow lacks fault paths for failed lookups, creates, updates, or deletes
- Metadata Dependency Risk: Flow will fail if any Countries_Group_X__mdt records are missing
- Infinite Loop Potential: No safeguards against recursive execution if account updates trigger this flow
HIGH - Address Soon After Go-Live¶
- Performance Concerns: Complex flow with multiple database operations could impact performance
- Hardcoded Group Names: Buyer group identification uses "Contains" logic with hardcoded strings
- Bulk Processing: No optimization for bulk account processing
- Data Consistency: No rollback mechanism if partial processing fails
MEDIUM - Future Enhancement¶
- Group Management: Consider more flexible buyer group identification beyond hardcoded name matching
- Address Validation: ContactPointAddress creation lacks validation of required fields
- Historical Tracking: No audit trail of buyer group assignment changes
LOW - Monitor¶
- Edge Cases: Behavior undefined if country exists in multiple metadata types
- Address Conflicts: Multiple ContactPointAddress records could cause confusion
- Performance Monitoring: Watch for delays during high-volume account updates
Maintenance Notes¶
This is a highly complex flow with significant business impact on international commerce operations. The multiple metadata dependencies and buyer group logic require careful maintenance. Recommend: - Monthly validation of Countries_Group_X__mdt completeness - Quarterly review of buyer group assignment accuracy - Regular monitoring of flow performance and error logs - Comprehensive testing before any metadata or buyer group changes - Consider breaking into smaller, more manageable sub-flows for better maintainability