Flow Name: Update User Name fields when the Account Name fields are updated¶
Last Updated: 2025-07-28 Source Code: Update_User_Name_fields_when_the_Account_Name_fields_are_updated.flow-meta.xml
API Name: Update_User_Name_fields_when_the_Account_Name_fields_are_updated Status: Active Type: Custom Trigger: After Account update when name or email fields change
Business Purpose¶
Maintains synchronization between Person Account name fields and related User records, ensuring user profiles display current information. When email changes, publishes platform event to trigger username update and password reset. Referenced in PR-33277.
Process Flow¶
- Triggers after Account update when any of these fields change:
- FirstName
- LastName
- MiddleName
-
PersonEmail
-
Retrieves related User record by AccountId
-
Validates User was found
-
Email Change Path:
- If PersonEmail changed: Creates Update_User_Username__e platform event with:
- AccountID__c: Account ID
- UpdatedEmail__c: New PersonEmail
- isCustomerUser__c: IsCustomerPortal flag
-
Platform event triggers separate flow to update username and send password reset
-
Name Change Path:
- Updates User record directly:
- User.FirstName = Account.FirstName
- User.LastName = Account.LastName
- User.MiddleName = Account.MiddleName
- Saves User record
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: Account Update<br/>After Save<br/>Name or Email Changed]) --> GetUser[Get Related User Record:<br/>By AccountId]
GetUser --> CheckUser{User Found?}
CheckUser -->|No| End([End])
CheckUser -->|Yes| CheckEmail{PersonEmail<br/>Changed?}
CheckEmail -->|Yes| CreateEvent[Create Platform Event:<br/>Update_User_Username__e<br/>• AccountID__c<br/>• UpdatedEmail__c<br/>• isCustomerUser__c]
CheckEmail -->|No| UpdateNames[Update User Names:<br/>• FirstName<br/>• LastName<br/>• MiddleName]
CreateEvent --> End
UpdateNames --> UpdateUser[Update User Record]
UpdateUser --> End
style Start fill:#e1f5ff
style GetUser fill:#f0e1ff
style CheckUser fill:#fff4e1
style CheckEmail fill:#fff4e1
style CreateEvent fill:#ffe1e1
style UpdateNames fill:#e1ffe1
style UpdateUser fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Only processes Person Accounts (implicitly, via PersonEmail field)
- Email changes trigger asynchronous username update via platform event
- Name changes update User synchronously in same transaction
- IsCustomerPortal flag determines if password reset email is sent
- No validation that User fields can be updated
Dependencies¶
- Objects: Account (Person), User
- Platform Event: Update_User_Username__e
- Event Fields: AccountID__c, UpdatedEmail__c, isCustomerUser__c
- Related Flows: Update_User_Email_and_Username (consumes platform event)
- Account Fields: FirstName, LastName, MiddleName, PersonEmail, IsCustomerPortal
Changes¶
PR-33277: User Name fields are updating when Account Name fields are updated.
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- Missing Error Handling: No fault paths for User update or platform event creation
- No Null Check: Doesn't verify User record exists before updating fields
- Mixed Transaction Model: Name updates are synchronous, email is async - could cause inconsistency
HIGH - Address Soon After Go-Live¶
- Partial Updates: If User update fails, Account changes are saved but User is not updated
- No User Notification: Users aren't notified their profile information changed
- Permission Issues: May fail if running user lacks permission to update User records
MEDIUM - Future Enhancement¶
- Error Logging: Log failures to update User records for admin review
- Audit Trail: Track when User fields are auto-updated from Account
- Validation: Add validation that name fields are populated before updating User
- Consistent Pattern: Consider making all updates async via platform event for consistency
LOW - Monitor¶
- Update Failures: Monitor for Accounts updated but related Users not synced
- Platform Event Delivery: Verify email change events are published successfully
- User Experience: Watch for user confusion when profile info changes automatically
Maintenance Notes¶
Complexity: Medium - Mixed sync/async pattern with platform event Review Schedule: Review when user provisioning or account management processes change PR-33277 Impact: Recent addition - monitor for unexpected behaviors Async Email Updates: Email changes are async which adds complexity but prevents blocking Paired Flow: Works with Update_User_Email_and_Username for complete sync Transaction Safety: After-save trigger ensures Account changes are committed first Critical User Data: Changes affect login and profile - test thoroughly before deploying