I am trying to create a user as below,

User u = new User();
u.Username = userName;
u.Email = email;
u.firstName = firstName;
u.lastName = lastName;
u.CommunityNickname = communityNickname;
u.ProfileId = MyUtil.getProfileId();

but i am getting error at last line as below,

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


This sounds very much like a permissions issue to me.

There are a couple of things to check here:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.