How to write Page Reference for Save in Lightning Component?

Use e.force:createRecord.

Sample Code:

Component:

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" >
    
    <lightning:button label="Create Account" onclick="{!c.createRecord}"/>
    
</aura:component>

Controller:

({
    createRecord : function (component) {
        var createRecordEvent = $A.get("e.force:createRecord");
        createRecordEvent.setParams({
            "entityApiName": "Account"
        });
        createRecordEvent.fire();
    } 
})

Once the create record event is fired, it will take to you the newly created account record.

No comments:

Post a Comment