0
votes

I have person accounts enabled and i am trying to allow my users to self register for communities and i am looking to configure the CommunitiesSelfRegController apex class to allow it. I understand adding a profile id and a role id but i cant understand why i have to add an account id. I understand why it needs to attach the user to an account but i don't want to attach them to an existing account, that doesn't make any sense for me and my business case (i cant see how it would suit most people but anyway). So i think i am asking: Is there a way that i can get this class to allow users to self register and it will create them an (person) account and a user with community access? or Is there a way to create a separate object and make a form which inserts all of the data i need then use a trigger or something to create a record on accounts, enable it for communities and create the appropriate user.

I hope i have made sense. I'm not a trained developer and i'm getting a bit out of my depth. Thanks in advance and all help is much appreciate.

Adam

1

1 Answers

0
votes

Adam

I am looking at the same item.

In the generated CommunitiesSelfRegController class, the main line is :

String userId = Site.createPortalUser(u, accountId, password);

Site.createPortalUser creates a contact for User and Account.

For person accounts, the Site class has createPersonAccountPortalUser(...) Doc Link is http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm#apex_System_Site_createPersonAccountPortalUser_2

Looks like this will do the job of create a PersonAccount all in one function.

Thanks Matthew