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