You need to sign in to do that
Don't have an account?
Joseph Ferraro
Register customer portal user, link with existing Person Account
Hi, we're building a customer portal where users will be registering as Person Accounts. The issue is that the Person Accounts most likely already exist in our org. So we want them to self-register on our portal and have their Custom Portal User associated to the Person Account that already exists in our org. Is this possible with the Site.createPersonAccountPortalUser() method? If not, how can we achieve this?
Thanks much
EDIT: is the solution to simply use Site.createPortalUser() with the id of the Person Account id?
If you want to create a customer portal user through site then you can use site.createportaluser(). Find below a sample code to create a portal user :
RecordType RecTypeOrg = [Select Id, Name from RecordType where name ='Individual' limit 1];
Account accInd = [Select Id, Name,RecordTypeId from Account where name ='Person' and RecordTypeId =:RecTypeOrg.id limit 1];
User u = new User();
u.Username = Email;
u.FirstName = FirstName;
u.LastName = LastName;
u.Email = Email;
u.CommunityNickname = communityNickname;
String pwdd = Passwd;
system.debug('<< before create user >>');
String userId = Site.createPortalUser(u, accInd.id, pwdd);
Hope this helps.