We are rolling out a community for our customer base and I am attempting to create an Batch Class to create and activate OR deactivate Community Users based on when they have been deemed to be active by a Designated user from their organization. Our Account-Customer structure is not standard - Most of our Contacts do not role up to an Account.
I am running into an issue when attempting to insert my new Users because I don't have specific fields related to Role populated. When we create an External User via the Salesforce UI, the role is automatically created as " Customer User". However, when I am creating them through the Apex Batch, I don't do so.
Must I create the UserRole for the Account prior to inserting the User? Is there something that I am missing where Salesforce should do this on my behalf?
Two things would be helpful to me:
- A list of the minimum fields that must be present to create a new Community User from a Contact that has an Account.
- a Blog post or Salesforce Documentation that outlines what happens on the backend when creating a Community User.
Or is there a really easy built in Class/Method that I am unaware of that would solve this problem for me and make me feel really dumb for not having found it yet?