function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Malik ButlerMalik Butler 

Case comments in visualforce pdf

I am trying to add case comments into a visualforce pdf I'm making. I want to see the most recent comment displayed and I've tried {!Case.Last_Case_Comment} as well as {!Case.CaseComments}, {!Case.CaseComments.CommentBody} and nothing seems to work. Using {!Case.CaseComments} It shows the ID so I think I just need the last piece to finish this but I'm unsure where to go. Please help!!
<table border="3">
  <tr style="font-weight: bold;font-color:Black;">
   <td colspan="1" bgcolor="#9FC6F9">Work Performed</td>
     </tr>
  <tr width = "100%">
    <td  style="height:45px;" width = "5%">{!Case.CaseComments}</td>
    <br/>
  </tr>         
</table>
Best Answer chosen by Malik Butler
Deepali KulshresthaDeepali Kulshrestha
Hi Malik,

You can modify this code according to your requirement and apply CSS according to your need.

<apex:column >
        <apex:facet name="header">Case Comment</apex:facet>
        <apex:outputText rendered="{!IF(v.CaseComments.size > 0, TRUE, FALSE)}">
         <apex:outputText > {!v.caseComments[0].CommentBody}  </apex:outputText>
        </apex:outputText>
</apex:column>  

Or you can try this also.

<apex:tab id="commentsTab" label="Comments">
    <apex:pageBlock>
        <apex:pageBlockTable value="{!case.casecomments}"var="c">
            <apex:column value="{!c.commentbody}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:tab>

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha

All Answers

Deepali KulshresthaDeepali Kulshrestha
Hi Malik,

You can modify this code according to your requirement and apply CSS according to your need.

<apex:column >
        <apex:facet name="header">Case Comment</apex:facet>
        <apex:outputText rendered="{!IF(v.CaseComments.size > 0, TRUE, FALSE)}">
         <apex:outputText > {!v.caseComments[0].CommentBody}  </apex:outputText>
        </apex:outputText>
</apex:column>  

Or you can try this also.

<apex:tab id="commentsTab" label="Comments">
    <apex:pageBlock>
        <apex:pageBlockTable value="{!case.casecomments}"var="c">
            <apex:column value="{!c.commentbody}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:tab>

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
This was selected as the best answer
Malik ButlerMalik Butler
Thank you so much for the help! I was able to get this to display no problem!
Malik ButlerMalik Butler
If there are more than one case comments is there anything I should do differently to get the most recent comment?