System.SObjectException: Field is not writeable: User.ProfileId

If you are trying to create users using apex and if you face "System.SObjectException: Field is not writeable: User.ProfileId" issue, remove with sharing keyword from the class.

The reason behind this is external users or guest users and so on will not have access to ProfileId field in user object.


No comments:

Post a Comment