You need to sign in to do that
Don't have an account?
SFDEV Thor
Site.createPortalUser() takes approx 20-25 seconds for first user registration of the day? Why?
We have a Lightning Community and enabled Self Registration.
The issue is weird. It takes approx 20-25 seconds for the very first User registration of the day and all user registrations onwards take only 2.5-3 seconds. We are facing this problem on normal sandbox as well as on partial sandbox also.
Code snippet is as below:
Please advise what might be taking so long time for simple User registration.
Note: We don't have any other failure in code or complete process, its all about long execution time for only first user registration of the day.
Thanks.
The issue is weird. It takes approx 20-25 seconds for the very first User registration of the day and all user registrations onwards take only 2.5-3 seconds. We are facing this problem on normal sandbox as well as on partial sandbox also.
Code snippet is as below:
public void registerUser(String newUserJson) { // This is the input, received from an Lightning Component Contact userContact = (Contact)JSON.deserialize(newUserJson, Contact.class); // This Account has Owner which has role - No issue here Account userAccount = [SELECT Id FROM Account WHERE Name = 'Individual' LIMIT 1]; Profile userProfile = [SELECT Id FROM Profile WHERE Name = 'ABC Community User' LIMIT 1]; // Setup User data User newUser = new User(); newUser.UserName = generateUniqeUserName(userContact.Email); newUser.Email = userContact.Email; newUser.FirstName = userContact.FirstName; newUser.LastName = userContact.LastName; newUser.ProfileId = userProfile.Id; // If using site to host the community the user should not hit s1 after logging in from mobile. String networkId = Network.getNetworkId(); if (networkId != null && siteAsContainerEnabled(Network.getLoginUrl(networkId))) { newUser.UserPreferencesHideS1BrowserUI = true; } // Compute dynamic nickname for user String nickname = ((userContact.FirstName != null && userContact.FirstName.length() > 0) ? userContact.FirstName.substring(0, 1) : '' ) + userContact.LastName.substring(0, 1); nickname += String.valueOf(Crypto.getRandomInteger()).substring(1, 7); newUser.CommunityNickname = nickname; // First Create Contact userContact.AccountId = userAccount.Id; INSERT userContact; // Create User newUser.ContactId = userContact.Id; String userId = Site.createPortalUser(newUser, userAccount.Id, password, true); } public static boolean siteAsContainerEnabled(String communityUrl) { Auth.AuthConfiguration authConfig = new Auth.AuthConfiguration(communityUrl, ''); return authConfig.isCommunityUsingSiteAsContainer(); } public static String generateUniqeUserName(String email) { return email + ((isSandbox() == true) ? '.abc.sandbox' : '.abc'); } public static Boolean isSandbox() { return [SELECT Id, Name, OrganizationType, NamespacePrefix, InstanceName, IsSandbox FROM Organization].IsSandbox; }
Please advise what might be taking so long time for simple User registration.
Note: We don't have any other failure in code or complete process, its all about long execution time for only first user registration of the day.
Thanks.
Can you check with your network connection