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
cooltubcooltub 

Add customer portal users to different accounts based on parameter

Hi

 

Is it possible to add Customer portal users to self register themselves and add as contacts of the account id passed as parameter. 

 

I know that we can hardcode Account ID in SiteRegisterController Apexclass to assign all the self register contacts to that account, but is it possible to add them dynamically to different accounts passed as parameter?

Best Answer chosen by Admin (Salesforce Developers) 
Pan_AKPan_AK

Yes we can do that .Just Query the Account which You want to associate as customer portal user and Pass the id of that Account As a argument in Site.createPortalUser .But Make sure the Owner of the Account Must have a role .

All Answers

Pan_AKPan_AK

Yes we can do that .Just Query the Account which You want to associate as customer portal user and Pass the id of that Account As a argument in Site.createPortalUser .But Make sure the Owner of the Account Must have a role .

This was selected as the best answer
cooltubcooltub

Hi Pan_AK,

 

Thanks for replying. I'm a newbie here, Can you explain in detail please? 

Ispita_NavatarIspita_Navatar

Hi,

      If you are creating a customer portal user through sites using -

           site.createportaluser(u, accoundid, optional, optional(included in winter'12))

  • the function receives a fourth parameters now
  •  second parameters is accoundid parameter for which you can fetch the account using SOQL query and bind it with the Customer portal user.

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

cooltubcooltub

Hi Ispita,

 

I have added the following lines to SiteRegisterController Apexclass. I'm trying pass account id as parameter and assign it to PORTAL_ACCOUNT_ID. But when i try to self register contacts are added to that account.

 

 public static Id accid;   

 

 public SiteRegisterController () {   

accid = ApexPages.currentPage().getParameters().get('Id');}

   

private static Id PORTAL_ACCOUNT_ID = accid;

 

 

cooltubcooltub

Thanks Pan_AK  and Ispita that worked! 

 

Can you please look into this post as well?

 

http://boards.developerforce.com/t5/Visualforce-Development/Form-with-master-detail-lookup-field-automatically-populated/td-p/358091