To display the record create page for an object, set the object name on the entityApiName attribute and fire the event. recordTypeId is optional and, if provided, specifies the record type for the created object. defaultFieldValues is optional and, if provided, specifies values to use to prepopulate the create record form.
createRecord : function (component, event, helper) { var createRecordEvent = $A.get("e.force:createRecord"); createRecordEvent.setParams({ "entityApiName": "Contact" }); createRecordEvent.fire(); }
The defaultFieldValues attribute lets you prepopulate the create record form with default or calculated field values. Prepopulated values can accelerate data entry, improve data consistency, and otherwise make the process of creating a record easier. Specify default field values as name-value pairs in a JavaScript object.
var createAcountContactEvent = $A.get("e.force:createRecord"); createAcountContactEvent.setParams({ "entityApiName": "Contact", "defaultFieldValues": { 'Phone' : '415-240-6590', 'Account' : '001xxxxxxxxxxxxxxx' } }); createAcountContactEvent.fire();
You can’t prepopulate system-maintained fields, such as Id or record modification time stamps. Default values for these fields are silently ignored.
Prepopulating rich text fields is unsupported. It might work for simple values, but the internal format of rich text fields is undocumented, so setting complex values that include formatting is problematic. Use at your own risk.