Wednesday, December 28, 2011

Multiple Users for a contact in SalesForce Customer Portal

This article discusses about
  • Creating Multiple Users for the same contact in Customer Portal

While there is already an article on SalesForce wiki about creating a customer portal user, it doesn't address my case of creating users through a trigger instead of the visual force page.  Also, the user creation is not dependent on the contact creation but creation of a contact's child record.  Before I jump into the nuts and bolts of the things, let me give a background.  (Here I assume that you have an understanding of how single sign-on works.  SalesForce has a very good article describing single sign-on process in salesforce.  This article only deals with traditional SAML 2.0 federation authentication as salesforce supports only this type of authentication of Customer Portals.

Background
Recently, I came across an issue related to the single sign-on integration with salesforce.  The existing identity provider system identifies users by the subscription ids.  For example, if John Smith has three subscriptions (S100, S200 and S300), then John is identified by the IDP as a three users who have access to the system.  In SalesForce, we have created Subscriptions of Contact.  So, subscription details (start date, end date, payment, active/inactive, etc..) is the child of the Contact.  That means that we have cannot use subscription IDs to create users; as SFDC only allows one user per contact.  You cannot create multiple portal users for the same contact




Implementation
This implementation only addresses the test case and trigger that was developed as a proof of concept to show how we cannot create multiple portal users for the same contact


First we account and contact in the test case