Flow Name: Customer Account Setup && Customer User Button Control¶
Last Updated: 2025-07-14 Source Code: On_user_creation_Async.flow-meta.xml
API Name: On_user_creation_Async Status: Active Type: Custom Trigger: After Save - User Record Create (with AsyncAfterCommit path)
Business Purpose¶
This flow handles two critical post-user-creation tasks: (1) creates Person Accounts for internal AANP staff users when they are manually created in Salesforce, and (2) manages the visibility of the "Create customer user" button by updating the Account field when portal users are created for existing Person Accounts.
Process Flow¶
- Trigger: Flow executes after User record is created
- Async Processing: Uses AsyncAfterCommit to avoid transaction limits
- Contact ID Check: Determines if user has associated Contact (external user)
- If ContactId exists: Updates related Person Account to hide customer user button
- If no ContactId: Proceeds to staff account creation logic
- Profile Validation: For users without ContactId, checks if profile matches staff types:
- System Administrator (Custom)
- AANP Standard User
- Helpdesk Support
- Record Type Lookup: Gets PersonAccount RecordType for staff account creation
- Staff Account Creation: Creates Person Account with staff-specific settings and organization address
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: After Save - User Record Create (with AsyncAfterCommit path)]) --> Screen[Display Screen:<br/>User Input Required]
Screen --> UserInput[User Enters Data]
UserInput --> Process[Process Input]
Process --> Action[Execute Action]
Action --> End([End])
style Start fill:#e1f5ff
style Screen fill:#fff4e1
style UserInput fill:#e1ffe1
style Process fill:#ffe1e1
style Action fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Only processes User records on creation (not updates)
- External users (with ContactId): Updates Account.Create_customer_user__c = false
- Internal users (no ContactId + staff profiles): Creates new Person Account
- Staff accounts automatically get:
- Member_Type__c = "Staff"
- Membership_category__c = "All Individual Members"
- Membership_status__c = "Never member"
- Address_Mailing_Company__c = "AANP"
- Organization address copied to PersonMailing fields
- Phone_Type__c = "Work", Person_Mailing_Address_Type__c = "Work"
Dependencies¶
- User object with ContactId field
- Account object with Create_customer_user__c field
- Account PersonAccount RecordType must exist
- Organization object for address information
- Person Account functionality enabled
Changes¶
- PR-29737: Create Person Account with Member type Staff for internal AANP Users
- PR-30960: Hide "Create customer user" button from Person Account when portal user exists
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- Hardcoded Profile Names: Three profile names are hardcoded - will break if profiles are renamed or new staff profiles added
- Missing Error Handling: No fault paths for RecordType lookup failure or Account creation failure
- RecordType Dependency: Complete failure if PersonAccount RecordType doesn't exist
HIGH - Address Soon After Go-Live¶
- Organization Address Assumption: Assumes Organization object has complete address - no null checking
- Bulk User Import Impact: AsyncAfterCommit could cause performance issues during bulk user imports
- Profile Management: No easy way to add new staff profiles without modifying flow
MEDIUM - Future Enhancement¶
- Configuration Management: Make staff profiles configurable through Custom Metadata or Settings
- Address Validation: Add validation for Organization address fields before copying
- Audit Trail: No logging of which users trigger account creation
- Member Type Logic: Consider making member type/category dynamic based on user attributes
LOW - Monitor¶
- Field Mapping: Many hardcoded values could be made configurable
- Organization Data: Monitor for incomplete Organization address data
- RecordType Changes: Monitor PersonAccount RecordType stability
Maintenance Notes¶
This is a MEDIUM COMPLEXITY flow that handles critical user onboarding processes for both external and internal users. It directly impacts: - Staff user setup and Person Account creation - External user portal access control - Account record data integrity
Security Considerations: - Creates Person Accounts for internal staff - Controls customer user creation button visibility - Uses organization-wide address data
Performance Considerations: - Uses AsyncAfterCommit to avoid transaction limits - Single SOQL query for RecordType lookup - Could impact bulk user creation processes
Recommended Review Schedule: - Before any User object or Profile changes - Quarterly review of staff profile list - Before bulk user import projects - When Person Account structure changes
Critical Dependencies: Organization object address data, PersonAccount RecordType stability, staff profile naming conventions