Flow Name: On Create customer user: Manual Creation of Portal and Buyer user¶
Last Updated: 2025-07-16 Source Code: On_Create_customer_user_Custom_Create_a_Buyer_user.flow-meta.xml
API Name: On_Create_customer_user_Custom_Create_a_Buyer_user Status: Active Type: Custom Trigger: Auto-launched Flow (called by other flows/processes)
Business Purpose¶
This flow automates the creation of external community users (buyer/shopper users) for Person Accounts or Contacts. It creates community users with the appropriate profile, permissions, and settings, then uses platform events to assign the necessary permission set groups. This is critical for enabling customers to access the e-commerce portal.
Process Flow¶
- Input Processing: Accepts recordId (Account or Contact) and migration flag
- Record Type Detection: Determines if input is Account (001) or Contact
- Contact Resolution: Gets Contact record (directly or from Person Account)
- Contact Validation: Ensures Contact record exists before proceeding
- User Existence Check: Verifies if user already exists for this Contact
- Profile Lookup: Retrieves "AANP External Identity" profile
- User Creation: Creates new User record with extensive field population
- Permission Set Group Lookup: Finds "AANP_Commerce_Shopper" permission set group
- Platform Event: Creates User_Creation__e event to trigger permission assignment
- Account Update: Updates Create_customer_user__c flag when user exists
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: Auto-launched Flow (called by other flows/processes)]) --> Lookup[Lookup Related Data]
Lookup --> Found{Data<br/>Found?}
Found -->|No| End([End])
Found -->|Yes| Calculate[Calculate/Determine Values]
Calculate --> Update[Update Records]
Update --> End
style Start fill:#e1f5ff
style Lookup fill:#f0e1ff
style Found fill:#fff4e1
style Calculate fill:#e1ffe1
style Update fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Only processes if Contact record is found
- Will not create duplicate users (checks existing User by ContactId)
- Hardcoded timezone: America/Chicago
- Hardcoded currency: USD
- Hardcoded language/locale: en_US
- Username format: {Email}{TODAY}
- Nickname format: {Email}{TODAY} (right 40 characters)
- Alias: First 5 characters of LastName
- Marks users as migrated when var_SetAsMigratedUsers = true
- Uses platform events for permission assignment to avoid governor limits
Dependencies¶
- Contact object with required fields (Email, FirstName, LastName, etc.)
- Account object with Create_customer_user__c field
- Profile: "AANP External Identity" must exist
- PermissionSetGroup: "AANP_Commerce_Shopper" must exist
- Platform Event: User_Creation__e
- Person Account functionality enabled
Changes¶
- PR-29601: Allow manual creation of person account
- PR-31281: Allow creation of business accounts
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- Hardcoded Values: Timezone, currency, and locale are hardcoded - not suitable for international users
- Username Collision Risk: Username formula using EMAIL+TODAY() could create collisions if multiple users created same day
- Missing Error Handling: No fault paths for user creation failures or platform event failures
- Profile Dependency: Complete failure if "AANP External Identity" profile doesn't exist
- Permission Set Dependency: No fallback if "AANP_Commerce_Shopper" permission set group missing
HIGH - Address Soon After Go-Live¶
- Platform Event Reliability: No confirmation that permission assignment platform event succeeds
- Bulk Operation Impact: No governor limit considerations for bulk user creation
- Email Validation: No validation that Contact has valid email before user creation
- Duplicate Prevention: Logic for existing users only updates flag but doesn't handle edge cases
MEDIUM - Future Enhancement¶
- Internationalization: Make timezone, currency, locale configurable based on Contact/Account data
- Audit Trail: No logging of successful/failed user creations
- Username Strategy: Consider more robust username generation to prevent collisions
- Configuration Management: Consider making profile/permission set names configurable
LOW - Monitor¶
- Formula Complexity: Username and nickname formulas could be simplified
- Field Mapping: Many hardcoded User field values could be made dynamic
- User Permissions: Review if all hardcoded user permissions are appropriate
Maintenance Notes¶
This is a HIGH COMPLEXITY, CRITICAL flow that creates external users for customer portal access. Any failure in this flow directly impacts customer onboarding and e-commerce functionality.
Security Considerations: - Creates external users with community access - Assigns commercial shopper permissions - Direct access to customer data through Contact relationships
Performance Considerations: - Uses platform events to avoid governor limits during bulk operations - Multiple SOQL queries per execution - User record creation with extensive field mapping
Recommended Review Schedule: - Before any major releases - Quarterly security review - Before bulk user migrations - When Permission Set Groups or Profiles change
Critical Monitoring: Monitor User_Creation__e platform event processing and permission assignment success rates