【问题标题】:Salesforce - Aura Component publish using message service issueSalesforce - Aura 组件发布使用消息服务问题
【发布时间】:2020-10-07 11:15:50
【问题描述】:

我正在尝试将数据从 Aura 发布到 LWC。我收到错误以纠正我所缺少的。 我检查了多个示例作为语法明智,仍然没有工作。因此发帖看看有没有人可以帮忙。

Aura 组件 html:

<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
   <a href="javascript:void(0);" onclick="{!c.publishMC}">More Information</a>
   <lightning:messageChannel type="AlertMessageChannel__c" aura:id="AlertMessageChannel"></lightning:messageChannel>
</aura:component>

光环控制器 JS:

({
publishMC : function(component, event, helper) {
    var messageInfo = [
        { normalTxt: '', boldTxt: '', boldLeftTxt: 'This opportunity is Stale', 
        normalRightTxt: 'the stale reason code is EOD PAST DUE.'},
        { normalTxt: '', boldTxt: '', boldLeftTxt: 'This account has 1 or more Frame 
         Agreements', normalRightTxt: 'There is a Frame Agreement associated to the account, 
         if applicable, please link to this opportunity using the Contract ID field.'},
    ];
    component.find("AlertMessageChannel").publish(messageInfo);
    }
})

我也添加了消息服务 xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<LightningMessageChannel xmlns="http://soap.sforce.com/2006/04/metadata">
<description>This is a alert message channel communicator</description>
<isExposed>true</isExposed>
<lightningMessageFields>
    <description>Header information passed into alert modal window</description>
    <fieldName>alertHeaderInfo</fieldName>
</lightningMessageFields>
<lightningMessageFields>
    <description>Body information passed into alert modal window</description>
    <fieldName>alertBodyInfo</fieldName>
</lightningMessageFields>
<lightningMessageFields>
    <description>Show/Hide information passed into alert modal window</description>
    <fieldName>alertVisibleInfo</fieldName>
</lightningMessageFields>
<masterLabel>AlertMessageChannel</masterLabel>

但是当尝试加载时,出现错误:

操作失败:闪电:messageChannel$controller$init [闪电消息服务 - 无法识别的消息通道参考:AlertMessageChannel__c]

谁能帮帮我,我错过了什么?

【问题讨论】:

    标签: salesforce-lightning


    【解决方案1】:

    该消息似乎表明您的消息频道未被识别。 “masterLabel”不是您的消息通道的 API 名称,而是文件名。例如,如果您在文件 AlertMessageChannel.messagechannel-meta.xml 中定义了您的 xml,那么您可以使用“AlertMessageChannel__c”引用您的频道。如果您的文件名不同,例如“TestChannel.messageChannel-meta.xml”,那么您必须使用“TestChannel__c”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-07
      • 2017-08-01
      • 2014-05-02
      相关资源
      最近更新 更多