[SalesForce] Create a Lightning Component button to open New Lead link

Need your help and thank you in advance.

Trying to create a lightning component that would invoke the New Lead Event action. For example from Lightning Experience in Winter 17, when you click the Lead tab, a drop down menu appears with the +New Lead selection, when clicked it will generate the New Lead popup window.

I'm looking for the lightning component syntax that would call the Lead's event handler when the end user presses a button on a lightning component (CREATE).

Is this even possible?

enter image description here

Best Answer

Yes it is possible using force:createRecord event handled by one.app container. You will have create a component that has a button.

component.xml

<ui:button press="{!c.createRecord}" label="Create Lead"/>

Controller.js

createRecord : function (component, event, helper) {
    var createRecordEvent = $A.get("e.force:createRecord");
    createRecordEvent.setParams({
        "entityApiName": "Lead"
    });
    createRecordEvent.fire();
}
Related Topic