Showing posts from July, 2014

Create a Salesforce User in Apex with all Required Fields Populated

Create a Salesforce User with Code in Apex with all of the Required Fields Populated for a Test Class When attempting to create a user with code in Apex you will encounter an error if you do not populate every single required field. You may be attempting to do this for a Test class or for any number of reasons. The error you encounter may look similar to the following: Missing fields Exception System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName, Email, Alias, TimeZoneSidKey, LocaleSidKey, EmailEncodingKey, ProfileId, LanguageLocaleKey]: [LastName, Email, Alias, TimeZoneSidKey, LocaleSidKey, EmailEncodingKey, ProfileId, LanguageLocaleKey] Create a User Many of those fields require specific values populated from a picklist. Below is some boilerplate code you can use to create a use programmatically with all of those fields populated correctly. You can use your own values for

Salesforce Combobox Autocomplete in IE8 using jQuery

Creating a Combobox Autocomplete Input Field Compatible with Internet Explorer 8+ using jQuery Issues with Built-in Combobox functionality in Visualforce If you try to use the off-the-shelf apex tag to using a inputText field to create a combobox by passing in a list of comma-separated values you will get a nasty surprise when you try to open the page in Internet Explorer. Even though IE is officially supported, it will not display correctly. Apex Default Combobox Tag <apex:inputtext list="{!getAccounts}" value="{!accountName}"></apex:inputtext> A great way to get around this limitation is to use the jQuery combo box. The jQuery combo box is not a standard widget and will not be packed into the jQuery UI by default, but you can configure it with a reasonable amount of code. You will need the following libs: jQuery javascript library - jQuery jQuery UI javascript library - jQuery UI Avoid conflicts wit