The user role created below is not 'High volume Portal User' but, still production deployment validation fails with error "FIELD_INTEGRITY_EXCEPTION, High Volume Portal Users cannot have a user role". Can someone help with this please?

enter image description here


Above issue got resolved by commenting out userRoleId assignment.


You should not define role for community users. Communities users get their roles automatically from their account. Try removing the UserRoleId field from User instantiation statement.

  • Hi Ashish, thanks for your response. When removed, the same test class fails saying " Portal account owner" must have role. – SFDC learner May 9 at 5:28
  • 1
    Check if user which is active in the context has a role assigned. User which is owner of the account must have a role to create a community user – Ashish Sharma May 9 at 6:32
  • 1
    As I can see you are using currently active user in System.runAs, so you should assign role to your user and make sure your deployment user has a role when you move the code to next environments – Ashish Sharma May 9 at 6:42

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.