Hi all I am using LNS(Lightning NavigationService) in LWC. I have created three buttons for New,Edit ,View in LWC on Account object where i am adding my component in Account record where i can clcik thee buttons i.e. On click of New button it will open New Account record STandard Record Page similarly for rest of buttons edit & view. But when i am click on each of these buttons i am getting error msg "Enter a valid URL and try again". Let me know what ihave missed
Hi all I am using LNS(Lightning NavigationService) in LWC. I have created three buttons for New,Edit ,View in LWC on Account object where i am adding my component in Account record where i can clcik thee buttons i.e. On click of New button it will open New Account record STandard Record Page similarly for rest of buttons edit & view. But when i am click on each of these buttons i am getting error msg "Enter a valid URL and try again". Let me know what ihave missed
import { LightningElement,api } from 'lwc';
import{NavigationMixin} from 'lightning/navigation'
export default class NavigationServiceLWC extends NavigationMixin(LightningElement) {
@api recordId;
navigateToNewRecordPage(){
this[NavigationMixin.Navigate]({
type:'standard__recordPage',
attributes:{
"recordId":this.recordId,
"objectApiName":"Account",
"actionName":"new"
}
});
}
navigateToEditRecordPage(){
this[NavigationMixin.Navigate]({
type:'standard__recordPage',
attributes:{
"recordId":this.recordId,
"objectApiName":"Account",
"actionName":"edit"
}
});
}
navigateToViewRecordPage(){
this[NavigationMixin.Navigate]({
type:'standard__recordPage',
attributes:{
"recordId":this.recordId,
"objectApiName":"Account",
"actionName":"view"
}
});
}
}
<!-- begin snippet: js hide: false console: true babel: false -->
<template>
<lightning-card title="Navigation Service in Lightning Web Components">
<lightning-card title="Navigate to Record Page">
<lightning-button-group>
<lightning-button label="New Record Page" onclick={navigateToNewRecordPage}></lightning-button>
<lightning-button label="Edit Record Page" onclick={navigateToEditRecordPage}></lightning-button>
<lightning-button label="View Record Page" onclick={navigateToViewRecordPage}></lightning-button>
</lightning-button-group>
</lightning-card>
</lightning-card>
</template>