Access the EmailMessagesList Related Page on the Visualforce for Case Page

I am trying to create a Visualforce page with a series of linked lists. I am trying to display the same linked lists that I have on a standard layout page. OpenActivities, ActivityHistories, Attachments, and CaseSolutions work fine.

However, when I try to add MailMessages, I get the following error.

Visualforce Error

"EmailMessages" is not a valid child relationship name for the Case entity

I can sort the work by getting EmailMessages using some soql, but I would really like it to be just a simple list.

Can anyone suggest what I can do wrong?

+4
source share
2 answers

Unfortunately, no, this is one of those things that the population as a whole never puts forward enough to realize them. EmailMessages linked list is not currently supported in <apex:relatedlist> Although you do not have to use SOQL to generate an unfiltered list, you can specify the value of the iterative element to retrieve data directly from the relation:

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

Here's a more complete example that uses a vertex: repeat with an HTML table. This approach allows you to adjust the line spacing. It also includes the ReplyToAll action. I plan to extend this example to more actions and put additional information in the info 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> 
+1
source

Source: https://habr.com/ru/post/1347750/


All Articles