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


Hi. I'm trying to create a portal user in a site but I can't seem to get a userId returned from site.createpersonaccountportaluser.  No matter what I do nothing comes back. obnoxious. Has anyone else had this problem and/or solved it?


Here's the code where it's called. Student is a contact that was just created.


pUser = new User();
pUser.FirstName = student.firstName;
pUser.lastName = student.lastName;
pUser.Username = student.Email;
pUser.Email = student.Email;
pUser.CommunityNickname = student.firstName.left(1) + student.LastName;
pUser.Alias = student.firstName.left(1) + student.LastName.left(4);
String ownerId = site.getAdminId();

for(integer i=0; i < 10; i++){
userId = Site.createPersonAccountPortalUser(pUser, ownerId, currRecType, pwSelect);
if(userId != null)break;

Wizno @ ConfigeroWizno @ Configero
What does your debug log show? There may be something missing...