You need to sign in to do that
Don't have an account?

Create user in VF and Apex - LICENSE_LIMIT_EXCEEDED
I have created a VF page and controller to add new user records, I am setting all relevant fields (I think), but I keep getting this error message:
Insert failed. First exception on row 0; first error: LICENSE_LIMIT_EXCEEDED, content feature license limit exceeded: []
I am setting profile, and have seen several posts that talk about setting the UserType but SF tells me that this field is not writeable.
I have plenty of licenses left in my dev org so not sure where the problem is. Am I missing a key field somewhere?
Here is the code excerpt:
Insert failed. First exception on row 0; first error: LICENSE_LIMIT_EXCEEDED, content feature license limit exceeded: []
I am setting profile, and have seen several posts that talk about setting the UserType but SF tells me that this field is not writeable.
I have plenty of licenses left in my dev org so not sure where the problem is. Am I missing a key field somewhere?
Here is the code excerpt:
// FIRST build default details based on current user // Establish current user and fetch details to copy currentUser = [select CompanyName, Country, EmailEncodingKey, LanguageLocaleKey, LocaleSidKey, TimeZoneSidKey, UserType from User where id = :UserInfo.getUserId()]; // Copy to new user object newUser = currentUser.clone(false, true); // Create all other details (NB: Fname, Lname, email in VF page) // Set user licence and profile if (sysAdmin) { newUser.ProfileId = sysAdminProfileID; } else { newUser.ProfileId = userProfileID; } // Set other fields newUser.isActive = true; newUser.UserRole = null; newUser.UserName = newUser.Email; newUser.Alias = createUserAlias(newUser.FirstName, newUser.LastName); newUser.CommunityNickname = newUser.FirstName; newUser.ReceivesInfoEmails = false; newUser.ReceivesAdminInfoEmails = false; newUser.UserPreferencesApexPagesDeveloperMode = false; // DML to ensure password generated Database.DMLOptions dmlo = new Database.DMLOptions(); dmlo.EmailHeader.triggerUserEmail = true; dmlo.EmailHeader.triggerAutoResponseEmail= true; newUser.setOptions(dmlo); try { insert newUser; } catch (exception e) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage())); return false; }
That's good to know, thanks for checking. I have managed to get it working in my dev org by switching off all the feature license details:
newUser.UserPermissionsCallCenterAutoLogin = false; Thanks
Russell
All Answers
And, if you run the code in a sandbox, please make sure the available license is enough in the production org.
That's good to know, thanks for checking. I have managed to get it working in my dev org by switching off all the feature license details:
newUser.UserPermissionsCallCenterAutoLogin = false; Thanks
Russell