Sforce Maximizer

Site.create user account creation issue on Multiple language website

If you have a multiple language website like spanish and you are trying to create a portal user account for a spanish user, the site.createPortaluser and site.createpersonaccount user may not work and here are the possible reasons for the problem.

1. To create the portal user, you need to have a owner id which you would do a soql query for the user object with system administrator account. Now you might have used a query like below which will not work for spanish user.

userList = [select id from user where (profile.name =: 'System Administrator'

and isactive=true and UserRoleId<> null

The reason is that the visual force page does a soql query against a user whose profile name is in spanish literal which breaks your code. So to fix this problem , here is what you would need to do.

if(language.equalsIgnoreCase('EN'))
{

userList = [select id from user where (profile.name =: 'System Administrator'
and isactive=true and UserRoleId<> null ) ];

OWNER_ID = userList[0].Id;
}else
{
userList = [select id from user where (profile.name =: 'Administrador del sistema'
and isactive=true and UserRoleId<> null ) ];

OWNER_ID = userList[0].Id;

}

Also make sure you set the user language to the preferred language on the user object before the account gets created. These 2 techniques would save you a lot of time to get multiple language sites done. Feel free to post your comments .

Exit mobile version