System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PortalType (Account is not enabled for this portal type): [PortalType] Exception in Salesforce due to the following reasons:
1. If you are trying to create UserRole for Partner Community licenses, then make sure the Account used in the PortalAccountId has IsPartner set to true.
2. If you are trying to create UserRole for Customer Community licenses, then make sure the Account used in the PortalAccountId is a Person Account.