Need to override the redirect on cancel of a force:createRecord lightning component. I am doing this but this is not working for me.

    doInit: function (component, event, helper) {
        var LOOKUP = 'MRU_LIST&backgroundContext=%2Flightning%2Fo%2FContact%2Flist%3FfilterName%3DRecent'; 
        var createAcountContactEvent = $A.get("e.force:createRecord");
            "entityApiName": "Contact",
            "defaultFieldValues": {
                'Phone' : '415-240-6590',
                'FirstName' : 'Himanshu',
                'LastName' : 'Sharma',
                'Description' : 'Hello how are you..??',
              "panelOnDestroyCallback": function(event) {
                window.location.href = "https://www.google.com";

Any help will be appreciated thanks in advance.

  • Instead of using window.location.href to redirect have you tried using the force:navigate type of events?
    – Kyle
    Commented Oct 10, 2019 at 14:08
  • yes i have tried. Commented Oct 11, 2019 at 13:08

1 Answer 1


panelOnDestroyCallback is not working after winter19 release idea and moreover panelOnDestroyCallback is undocumented solution. i would suggest to use regurlar Apex controller for save the Sobject record and then in success of server call redirect to next page or previous by using lightning:navigation events see the doc here

  • But i don't suppose to use custom buttons on my component. Commented Oct 11, 2019 at 9:58
  • you don't need to create custom button, in init function you can make Apex call for sobject record creation and then in success of server call you can navigate what ever you want. please update your Question with more details of your use case, so that it'll easy to give best solution.
    – sdandamud1
    Commented Oct 11, 2019 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .