Newer Version Available

This content describes an older version of this product. View Latest

force:createRecord

Opens a page to create a record for the specified entityApiName, for example, “Account” or “myNamespace__MyObject__c”.

To display the record create page for an object, set the object name on the entityApiName parameter and fire the event. recordTypeId is optional and, if provided, specifies the record type for the created object. This example displays the record create panel for contacts.

1createRecord : function (component, event, helper) {
2    var createRecordEvent = $A.get("e.force:createRecord");
3    createRecordEvent.setParams({
4        "entityApiName": "Contact"
5    });
6    createRecordEvent.fire();
7}

This event is handled by the one.app container. It’s supported in Lightning Experience and Salesforce1 only. This event presents a standard page to create a record. That is, it doesn’t respect overrides on the object’s create action.

Note

Attribute Name Type Description
entityApiName String Required. The API name of the custom or standard object, such as “Account”, “Case”, “Contact”, “Lead”, “Opportunity”, or “namespace__objectName__c”.
recordTypeId String The ID of the record type, if record types are available for the object.