2

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.

To resolve this i checked for backgroundContext. This is working fine for New record page navigation, but for edit the backgroundContext is not working.

i am trying to make the page see like this

enter image description here

but currently the background is coming as blank.

JS

  if (this.mode === 'edit') {
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                recordId: this.recordId,
                objectApiName: 'XYZ__c',
                actionName: 'edit'
            },
            state: {
                nooverride: 1,
                backgroundContext: '/lightning/r/XYZ__c/a2Q1j0000001nomEAA/view'
            }
        });
    }
0

I have just resolved the same problem. In the state attribute, you should add navigationLocation: 'DETAIL'. The state attributes are nearly undocumented. I have found that i should put DETAIL value in navigationLocation by inspecting the URL generated after a click on the standard edit button of the view page.

Here is a complete example :

generateBackgroundUrlAndEdit(record_id) {
        this[NavigationMixin.GenerateUrl]({
            type: 'standard__recordPage',
            attributes: {
                recordId: record_id,
                objectApiName: "XYZ__c",
                actionName: 'view'
            },
        }).then(url => {
            this.navigateToEditPage(record_id, url);
        });
    }

    navigateToEditPage(record_id, back_url) {
        console.log('Return page URL = ' + back_url);
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: record_id,
                objectApiName: 'XYZ__c',
                actionName: 'edit'
            },
            state: {
                nooverride: 1,
                navigationLocation: 'DETAIL',
                //backgroundContext: '/lightning/r/XYZ__c/a2h9E000000sqvrQAA/view'
                backgroundContext: back_url
            }
        });
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.