[SalesForce] Overriding the Cancel button of a force:createrecord lightning component

Created a aura component and have overrided this component with NEW standard button .
On click of save, record gets created and redirect happens successfully.
The problem is, while clicking the cancel button the page is not redirecting back to the standard list view page.

Below is my sample code. I have also tried all the various ways of destroying the component and redirecting to the list view but have not been sucessfull in redirecting back.

Any suggestions in this regard is highly appreciated.

var createAcountContactEvent = $A.get("e.force:createRecord");
                createAcountContactEvent.setParams({
                    "entityApiName": "Pipeline__c",
                    recordTypeId: recordTypeId,
                    "navigationLocation":"LOOKUP",
                    "panelOnDestroyCallback": function(event) {
                        var urlEvent = $A.get("e.force:navigateToURL");                           
                            urlEvent.setParams({
                                "url": "/lightning/o/Pipeline__c/home", 
                                "isredirect":true
                            });
                            urlEvent.fire();
                    }
                });
                createAcountContactEvent.fire();

Thank you!!!

Best Answer

Found this sample code while referring to the following ideas

https://success.salesforce.com/ideaView?id=0873A0000003VnmQAE

https://success.salesforce.com/ideaView?id=0873A000000CSXWQA4

Unsure if this will help but you can try something like this

    ({
    handleNewEngagement : function(component, event, helper) {

        let currentUrl = decodeURIComponent(window.location.search.substring(1));
        let createRecordEvent = $A.get("e.force:createRecord");

        createRecordEvent.setParams({
            "entityApiName": "Opportunity",
            "defaultFieldValues": {
                'Name' : 'Save to auto-populate',
                'AccountId' : component.get("{!v.recordId}")
            },
            "panelOnDestroyCallback":function(event) {
                var navEvt = $A.get("e.force:navigateToSObject");
                navEvt.setParams({
                    "recordId": component.get("v.recordId"),
                    "isredirect":true
                });
                // navigate back to account only if opportunity create was cancelled
                decodeURIComponent(window.location.search.substring(1)) == currentUrl ? navEvt.fire() : console.log('nav to opportunity');
            }
        });
        createRecordEvent.fire();
    }
})

Also, Does panelOnDestroyCallback work for you?

Anudeep