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

Delete Contact ID associated with customer portal user?

Is there any way to delete the contact record associated with a customer portal user?


I'm using a customer portal to self-regiser and authenticate users for a Site. The self-registration process creates both a user and contact record, as expected, but it seems there's no way to diassociate the contact record from the user record and to delete the contact - even for de-activated users...





You have to set the contactid field to null first and then delete the related contact.


Hope this helps...




Thanks for your reply.

I did try setting User.ContactId to null (using "Execute Anonymous" in the IDE; I am a System Admin for the org) -- but it doesn't work. The field User.ContactId is not updateable...




You could use apex data loader to do the same. First export the users, and delete the associated contacts. Then do an upsert of the users. Now you can export the contacts and do a delete operation.



John EastvoldJohn Eastvold
Since I've had to scoure the internet for the answer for this question twice in the last few years, here's the correct answer.

On the User record, set  "IsPortalEnabled" = FALSE.  This automatically sets "IsActive" = FALSE at the same time, and removes the link to the associated Contact. It severs the connection that restricts you from deleting the Contact records. 

You need to do this from a data tool (DemandTools, Data Loader, Informatica, etc.). You need to export a report of the records you want to affect with the data tool. The report needs to have the User ID and the Contact ID (I had to build a custom report type). It will be hard to get the Contact IDs after doing the update to the User records since the connection is severed.

- John
Andrew Mondy_Andrew Mondy_
Adding to John Eastvold's answer above, I have found that setting the field IsCustomerPortal = FALSE on the Person Account record will automatically cause the User record IsPortalEnabled and IsActive fields to be set to FALSE, remove the link to the Contact, and in adddition, it hides the Disable Customer User button on the Person Account record page. (This button is not hidden when using John's solution, however.) 

Hope that helps someone!