0

I have a lwc that is wrapped in a urlAddressable aura component. I did this so I can navigate to it from a button in a related list in a record page. This lwc has a "go back" button, which simply navigates back to the record I was before. It's a simple navigationMixin call:

this[NavigationMixin.Navigate]({
        type: 'standard__recordPage',
        attributes: {
            recordId: this.recordId,
            actionName: 'view',
        },
    })

So the thing is, when I go to the lwc, and try to go back, the url it generates is this:

/lightning/r/%20a0k0L00000DD7DDQA1/view

And salesforce throws an error saying the record doesn't exist anymore and that I should contact my administrator.

But then, if I refresh my lwc and try to go back, it fixes itself and navigates correctly. What I noticed is that the url it generates after refreshing is this one, which seems to be the correct url:

/lightning/r/ERPvs__Movimiento_Fondo__c/a0k0L00000DD7DDQA1/view

This url contains the name of the sObject between the /r/ and the Id itself.

Why is this happening? I can't really understand why it would generate two different urls, one that doesn't work right after navigating to the lwc and then after refreshing, the correct one.

0

I would add the objectAPIName parameter like so

this[NavigationMixin.Navigate]({
    type: 'standard__recordPage',
    attributes: {
        recordId: this.recordId,
        actionName: 'view',
        objectApiName: 'ERPvs__Movimiento_Fondo__c'
    },
})
1
  • perfect! thank you. Jun 23 '21 at 18:33

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.