4

我正在尝试创建一个包含许多相关列表的 Visualforce 页面。我正在尝试显示与标准布局页面上相同的相关列表。OpenActivities、ActivityHistory、Attachments 和 CaseSolutions 都可以正常工作。

但是,当我尝试添加 EmailMessages 时,出现以下错误。

Visualforce 错误

“EmailMessages”不是实体案例的有效子关系名称

我可以通过使用一些 soql 获取 EmailMessages 来解决它,但我真的希望它只是一个简单的相关列表。

谁能建议我可能做错了什么?

4

2 回答 2

2

不幸的是,不,这是普通民众从未充分支持以实施的事情之一。虽然目前EmailMessages不支持相关列表,<apex:relatedlist>但您不一定必须使用 SOQL 来生成未过滤的列表,您可以指向迭代元素的值以直接从关系中提取数据:

<apex:dataTable value="{!Case.EmailMessages}" var="email">
    <apex:column value="{!email.Subject}" />
    ...
</apex:dataTable>
于 2011-04-13T08:29:48.797 回答
1

这是一个使用 apex:repeat 和 HTML 表格的更完整示例。这种方法允许您调整行之间的间距。它还包括一个ReplyToAll 操作。我计划通过更多操作扩展此示例,并将更多信息放在电子邮件信息列中。

<apex:tab label="Email" name="Email2" id="tabEmail2">
    <apex:form >
        <apex:pageBlock id="emailPageBlock">
            <table border="0"  class="emailable">       
            <tr>
                <th class="emailActionColumn">Action</th>
                <th class="emailInfoClass">Information</th>
                <th class="emailBodyClass">Body</th>
            </tr>
            <!-- get the case comments from the controller -->
            <apex:repeat value="{!case.EmailMessages}" var="emsg">
                <tr>
                <td class="emailActionColumn">
                <!-- Rely to all -->
                <!-- 
                _ui/core/email/author/EmailAuthor?email_id=02s7000000Bi6uv&replyToAll=1&retURL=%2F02s7000000Bi6uv
                 -->
                <apex:outputLink title="" value="../_ui/core/email/author/EmailAuthor?email_id={!emsg.id}&&replyToAll=1&retURL=/apex/{!$CurrentPage.Name}%3Fid={!case.id}" style="font-weight:bold">Reply To All</apex:outputLink> 
                </td>
                <td>
                <!-- display the email information  -->
                <div class="emailInfoClass">
                <apex:outputField value="{!emsg.FromName}"></apex:outputField>
                </div>
                </td>
                <td>
                <!-- display the email body formatted using the apex outputField -->
                <div class="emailBodyClass">
                <apex:outputField value="{!emsg.TextBody}"></apex:outputField>
                </div>
                </td>
                </tr>
            </apex:repeat>
            </table>
        </apex:pageBlock>
    </apex:form>
</apex:tab>
于 2011-06-11T16:27:37.420 回答