function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mfordmford 

Enable portal user for existing contacts during sites self-registration

During the sites self-registration process, I have only come across the ability to create a portal user that creates both a contact and a user synchronously.  I would like to be able to create a portal user using an existing contact.  I tried setting the contact id on the user object before I called createPortalUser, but it still created a new contact.  We are trying to eliminate the possibility of duplicate contacts.

Best Answer chosen by Admin (Salesforce Developers) 
hgarghgarg

Hi,

 

I have faced such situations in this case , we are associating the existing contactId to the newly created user, we written our custom registration controller. hope it is clear.

All Answers

Ryan-GuestRyan-Guest

Currently there isn't a way to do that.

 

For preventing duplicates, would it be possible to query for similar accounts before the user registers?

EIE50EIE50

Hi,

 

As ryan said, i am just adding few lines to it.

 

You can write a controller where you can query for a contact, and if it exists then convert the contact in to a site user else create a contact and then convert the contact in to a site user.

 

We are doing this using a webservice call, i dont know whether you are using out of box site's self registration controller or something.

 

Thanks.

mfordmford

Yes, I am using the sites object to create the portal users and following the code from the out-of-the-box self-registration controller as an example.  I am querying for an existing contact, but I don't see a way to convert that existing contact to a site user.   The sites object just creates a duplicate contact.    Can you tell me how you are converting a contact to a site user?  Many thanks in advance :)

EIE50EIE50

Hi,

 

We use  webservice to do this. We have 4-5 separate methods, first to check for a contact, if not create the contact, then check for the user, if not create the user by associaing it with the respective contact. In the user insertion method, we have something like, newuser.ContactId = contact.Id; (contact.Id is being queried in the user creation method).

 

Thanks.

 

 

hgarghgarg

Hi,

 

I have faced such situations in this case , we are associating the existing contactId to the newly created user, we written our custom registration controller. hope it is clear.

This was selected as the best answer
Admin User 1137Admin User 1137
Hi,
Can u post the code in which you were able to enable new users under existing contact. It will help me alot...
Trenton BoormanTrenton Boorman
Is this still possible with communities?
As mentioned above any example code would be greatly appreciated. Thanks!
Syed Subhan 9Syed Subhan 9
Hi EIE50,
Can u post the code in which you were able to enable new users under existing contact. ASAP. It will be very very helpfull. As I don't do that level of SF work yet, so any help would be great.
 
Syed Subhan 9Syed Subhan 9
Hi hgarg,

Can u post the code in which you were able to enable new users under existing contact. ASAP. It will be very very helpfull. As I don't do that level of SF work yet, so any help would be great.