开发者

Accessing EmailMessages relatedList in Visualforce page for Case

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?


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>


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜