在案例的 Visualforce 页面中访问电子邮件消息相关列表

发布于 2024-10-31 23:39:14 字数 314 浏览 4 评论 0原文

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

但是,当我尝试添加电子邮件消息时,出现以下错误。

Visualforce 错误

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

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

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

I'm trying to create a Visualforce page with a number of related lists. I'm trying to display the same related lists that I have on the standard layout page. OpenActivities, ActivityHistories, Attachments and CaseSolutions all work fine.

However when I try to add EmailMessages I get the following error.

Visualforce Error

'EmailMessages' is not a valid child relationship name for entity Case

I'm able to sort of work around it by getting the EmailMessages using some soql, but I'd really like it to be just a plain related list.

Can anyone suggest what I might be doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟─花易冷 2024-11-07 23:39:14

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

<apex:dataTable value="{!Case.EmailMessages}" var="email">
    <apex:column value="{!email.Subject}" />
    ...
</apex:dataTable>

Unfortunately no, its one of those things that the general population never upvotes sufficiently to get implemented. For now EmailMessages related list is not supported in <apex:relatedlist> Though, you don't necessarily have to use SOQL to generate an unfiltered list, you can point iterating element's value to draw data directly from the relationship:

<apex:dataTable value="{!Case.EmailMessages}" var="email">
    <apex:column value="{!email.Subject}" />
    ...
</apex:dataTable>
还给你自由 2024-11-07 23:39:14

下面是一个更完整的示例,它将 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>

Here is a fuller example that uses apex:repeat with a HTML table. This approach allows you to adjust the spacing between rows. It also includes a ReplyToAll action. I plan on extending this example with more actions and put more information in the email info column.

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文