[英]Enter a valid URL and try again : Salesforce Lightning Web Component Error
Hi all I am using LNS(Lightning NavigationService) in LWC.大家好,我在 LWC 中使用 LNS(Lightning NavigationService)。 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.我在帐户 object 的 LWC 中创建了三个按钮用于新建、编辑、查看,我在帐户记录中添加了我的组件,我可以在其中单击按钮,即单击新建按钮时,它将打开新帐户记录标准记录页面,类似于 rest 的按钮编辑和查看。 But when i am click on each of these buttons i am getting error msg "Enter a valid URL and try again".但是当我单击每个按钮时,我收到错误消息“输入有效的 URL 并重试”。 Let me know what ihave missed让我知道我错过了什么
Hi all I am using LNS(Lightning NavigationService) in LWC.大家好,我在 LWC 中使用 LNS(Lightning NavigationService)。 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.我在帐户 object 的 LWC 中创建了三个按钮用于新建、编辑、查看,我在帐户记录中添加了我的组件,我可以在其中单击按钮,即单击新建按钮时,它将打开新帐户记录标准记录页面,类似于 rest 的按钮编辑和查看。 But when i am click on each of these buttons i am getting error msg "Enter a valid URL and try again".但是当我单击每个按钮时,我收到错误消息“输入有效的 URL 并重试”。 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对我来说也是同样的问题,但在我的情况下, recordid变量名中存在大小写问题
attributes:{
"recordId": this.recordid,
"objectApiName":"Account",
"actionName":"view"
}
Edit - Can you post this question on Salesforce's stackexchange?编辑 - 您可以在Salesforce 的 stackexchange 上发布这个问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.