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

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.

Cheers!!!

Leave a Reply