+ Start a Discussion
fitzpix6fitzpix6 

createPortalUser Method

Hello Team:
I'm debugging a portal issue trying to create a portal user from a Sites page. 
Here is the code I'm trying to execute:
try{
userId = Site.createPortalUser(u, accountId, password, true);
} catch (Exception e){
system.debug(' error in creating User Account ' + e.getMessage());
}

Here is my debug log:
14:43:20.744 (744838000)|METHOD_ENTRY|[118]|01pE0000001gvec|SiteRegisterController.__sfdc_password()
14:43:20.744 (744925000)|METHOD_EXIT|[118]|01pE0000001gvec|SiteRegisterController.__sfdc_password()
14:43:20.745 (745121000)|SYSTEM_METHOD_ENTRY|[118]|system.Site.createPortalUser(SObject, String, String, Boolean)
14:43:20.754 (754125000)|SYSTEM_METHOD_EXIT|[118]|system.Site.createPortalUser(SObject, String, String, Boolean)
14:43:20.754 ()|SYSTEM_METHOD_ENTRY|[138]|System.debug(ANY)
14:43:20.754 (754237000)|USER_DEBUG|[138]|DEBUG| userId == nul 

My try is not blowing up but the user is not getting created either. Any ideas?

 

Thank you,

fitzpix6fitzpix6

Hi, 

I figured this out my site was set up incorrectly, I needed to associate the site to the correct customer portal.  My question here is why wouldn't the API give me a response about how the portal can't create a user??

 

Thanks,

Ian

SamuelDeRyckeSamuelDeRycke
The documentation ( https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm) ) does mention "If there is a exception when using site.createPortalUser, a null is returned and the site system administrator is sent an email. For more information on sites, see “Force.com Sites Overview” in the Salesforce online help."  Possible these exceptions are caught by a different mechanism, and do not end up exposed to your apex execution context.