I have overridden standard edit page with a lightning controller which will redirect to standard lightning record page or custom lightning component by different recordtypes.
The problem i am facing is when i press the standard Cancel button which appears on the modal, it just closes the modal, but it doesn't reditrect to record detail page.
Onpage load i am check the action is New or Edit. Is there any work around how to handle Cancel button click event.
JS -
if(myPageRef.attributes.actionName === 'edit') {
var editRecordEvent = $A.get("e.force:editRecord");
editRecordEvent.setParams({
"recordId": myPageRef.attributes.recordId,
"nooverride":"1"
});
editRecordEvent.fire();
}
updated JS
if(myPageRef.attributes.actionName === 'edit') {
var pageReference = {
type: "standard__objectPage",
attributes: {
objectApiName: "Account",
actionName: "edit"
},
state: {
nooverride:'1',
backgroundContext:'/lightning/r/Account/0010K000028JP7SQAW/view'
}
};
component.set("v.pageReference", pageReference);
navService.generateUrl(pageReference)
.then($A.getCallback(function(url) {
}), $A.getCallback(function(error) {
}));
} else {
}