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 .

mm

Hi there! My name is Buyan Thyagarajan. I am a Salesforce consultant specializing in Higher Education, Manufacturing and Marketing Automation. My blogs will help you to maximize your Salesforce CRM investments, prevent problems beforehand and make the right decisions. If you need to talk to me right away, you can email me at buyan47@gmail.com or call me at 302-438-4097

Leave a Reply

Your email address will not be published. Required fields are marked *

Get free tips on Salesforce
Get free tips on Salesforce
We respect your privacy.