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 ie 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 ie 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>
Same issue for me as well, in my case however there was a casing issue in the recordid variable name
attributes:{
"recordId": this.recordid,
"objectApiName":"Account",
"actionName":"view"
}
Edit - Can you post this question on Salesforce's stackexchange?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.