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
VictorBVVictorBV 

Activating Customer Portal with Apex

Hi all

 

I am trying to Activate Customer Portal for Contacts of an Account with Apex so automatically I can create Users for a new contacts with a trigger just after Account and Contact are inserted, but I dont know how to do it.

 

I have already enabled the Customer Portal and I have created one portal, now I would like to automatically create Roles for an Account when it is inserted so when a Contact for that Account is inserted I can enable Login for Customer Portal for that user.

 

I studied the proccedure and I realize that, when first Contact is enabled to Login in Customer Portal 3 UserRoles and 6 Groups are created, related to the Account. I tried to do that with Apex and I couldnt beacuse RelatedId in Group is read only.

 

How can I do that?

 

Thanks in advance

 

 

hisrinuhisrinu

I have also faced the same issue 2years back and I did it manually. Now we can make use of @future call to create the portal user.

 

http://blog.sforce.com/sforce/2009/04/provisioning-customer-portal-users-with-apex.html

VictorBVVictorBV

Hi Srini,

 

I have checked that page before and it seems to be a bit old since it refers to User.ContactId field, but it does not exists right now (are least I can not see it with sforce Explorer).

On other hand, even if we ignore the previous point, when creating a User for a Contact... which Role should be used for that User?.

 

I hope someone can help me.

 

Thanks very much in advance.