Loading

Account Owner Change Fails with UNKNOWN_EXCEPTION Due to Duplicate PersonAccount Portal Role

Julkaisupäivä: Jul 31, 2026
Kuvaus
  1. UNKNOWN_EXCEPTION when updating Account Owner via UI or Apex.
  2. Issue does not reproduce in sandbox copies of production data (role/user split state doesn't always carry over identically).
  3. Two UserRole records exist for the same account owner, differing only by a trailing digit in DeveloperName, both with PortalRole = 'PersonAccount'
Ratkaisu
  1. Identify the affected user's PortalAccountOwnerId, then run:  
SELECT DeveloperName, Id, Name, ParentRoleId, PortalAccountId, PortalAccountOwnerId, PortalRole, PortalType
FROM UserRole
WHERE PortalRole = 'PersonAccount'
AND PortalAccountOwnerId = '<PortalAccountOwnerId>'
If this returns 2+ records (vs. 1 expected), duplicate portal roles are the cause.

2. Confirm which users are assigned to each role:

SELECT Id, Name, UserRoleId FROM User WHERE UserRoleId IN ('<roleId1>','<roleId2>')

3. The role without a numeric suffix in DeveloperName is the original/canonical role; the suffixed one (...1, ...2, etc.) is the auto-generated duplicate.

Pre-Deletion Safety Checks (run against the duplicate role's Id):

  1. Child roles: SELECT Id FROM UserRole WHERE ParentRoleId = '<duplicateRoleId>' → must be empty.
  2. Sharing dependencies: get the role's implicit groups via SELECT Id, Type, RelatedId FROM Group WHERE RelatedId = '<duplicateRoleId>', then check SELECT Id FROM AccountShare WHERE UserOrGroupId IN (<groupIds>) → must be empty (implicit Role/RoleAndSubordinates groups are expected/system-generated; the check is for *Share rows referencing them).

Resolution / Workaround:

  1. Reassign any user(s) on the duplicate role to the canonical role — do this via UI Edit → Save on the User record (not a raw API update), as this triggers Salesforce's role-resync behavior.
  2. Once the duplicate role has zero users, delete it — should succeed once pre-deletion checks above are clear.
  3. Retry the Account Owner change — should now complete successfully.

If the customer cannot delete the role even after removing users (DELETE_FAILED), check for child roles or sharing dependencies per step above before retrying.

Knowledge-artikkelin numero

005390305

 
Ladataan
Salesforce Help | Article