saveurl on createrecordevent or navigationlocation in lightning component

1.5k views Asked by At

I have a similar code as below.

createRecord : function (component) {
    var createRecordEvent = $A.get("e.force:createRecord");
    createRecordEvent.setParams({
        "entityApiName": "Case",
    "panelOnDestroyCallback": function(event) {
           $A.get("e.force:navigateToSObject").setParams({
                   recordId: component.get("v.recordId"),
                   slideDevName: "detail"
            }).fire();
     }
    });
    createRecordEvent.fire();
} 

It does not redirect to the record id i have provided and this code is not even calling the function inside "panelOnDestroyCallback".

I have also tried "navigationLocation": "LOOKUP" and I do know RELATED_LIST opens the same page i have called the createrecordevent.

I have also tried url redirect too inside that "panelOnDestroyCallback".

panelOnDestroyCallback is not even getting called in the code.

My intention is to send the page to account record detail page after it saved the case record which was opened from createrecordevent??

1

There are 1 answers

1
Arepa Slayer On

e.force:createRecord will automatically redirect you to the new record after creation. No need to define a custom callback for that.

<aura:component implements="flexipage:availableForAllPageTypes">
    <lightning:button label="Create Case" variant="brand" onclick="{!c.createRecord}"/>
</aura:component>
({
    createRecord : function (component, event, helper) {
        var createRecordEvent = $A.get("e.force:createRecord");

        createRecordEvent.setParams({
            "entityApiName": "Case"
        });

        createRecordEvent.fire();
    }
})