I'm getting the error below when creating external users (Site.createExternalUser) only when encryption is on and when adding new contacts after turning on the encryption to default fields.
We encountered an unknown error while processing this request
So it works for 2 out of 3 different scenarios, before starting I'd like to share some background about the environment and settings:
- The community is published
- The Account Owner does not have a User Role assigned
- The site guest user does have Create and Read permissions on the Account and Contact objects
- Self-registration is enabled for the community.
Scenario 1: Nothing is encrypted. It works!
Scenario 2: Create a contact, configure the email and then encrypt the default Salesforce fields (including email). It works! The external user is create without any issue!
Scenario 3: Everything is already encrypted, then after creating a new contact and waiting it to became available via SOSL (same as scenario 2) the process to self-register tries to create the external user. This is when we get the error "We encountered an unknown error while processing this request".
Note that if you disable encryption and enable it again, it works. However this workaround is unacceptable.
- Locate an existing contact by the email (encrypted/not encrypted depending on each scenario)
- Create a new user with same email
- Create external user
Finally, the question! Why scenario 2 and scenario 3 are not behaving exactly in the same manner? Why it works after decrypting/encrypting?
Note: Salesforce Case has been raised