Overview
This article explains why calling an event.user
operation in an action may result in the wrong user profile being returned in a scenario where there are multiple user profiles with the same user ID in two different connections.
Applies To
- User IDs
- Duplicate Users
Cause
This complication arises from having the same user IDs for two different users. event.user
will use the user ID of the logged-in user as an identifier and will not consider the connection as a qualifier - it will nondeterministically return the first user profile encountered with that user ID, so it may sometimes return the intended profile or a different profile
Solution
Change the user_id
for one of these duplicate profiles so they become unique within a tenant by following the steps from Updating Users with Duplicate user_ids:
- Create a new database connection (New-DB) that will be used to import duplicate users.
- Export users from one of the custom database connections and modify the user_id in the exported JSON to include a prefix of the new connection (for example, “New-DB|{unique-identifier}”) per documented best practices.
- Import the users with new user_id into the New-DB database.
- Delete the old database and enable to new database for the same applications.
If there are a large number of duplicate user IDs to clean up, consider identifying them using a Bulk User Export, iterating through the JSON or CSV, and using a set or hashmap-like data structure to input each user ID and perform a lookup on any future user IDs and see if they have been encountered before from the set or hashmap through a lookup.