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
Praveen JhaPraveen Jha 

display all public comment on case - Urgent

One of my case has 45 public and 75 private comment . Can we write a visulforce page to display all public comment on that case. We just want to display public comment  not private. 
Sagar PareekSagar Pareek
Yes you can query CaseComment to get all public comments make sure isPublished is true. 

https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_casecomment.htm

 
Praveen PosaPraveen Posa
Here you go : 

 Page: 

 <apex:page standardController="Case" extensions="CaseCommentsController" >
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!displayList}" var="dl" >
<apex:column headerValue="Public Case Comments" value="{!dl.CommentBody}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>


Class: 

 public with sharing class CaseCommentsController 
{
    
  public Id CaseId;
   
  public CaseCommentsController(ApexPages.StandardController stdController){
        CaseId = stdController.getId();
        system.debug('Case Id --> '+CaseId);
       
    }

 public List<CaseComment> getDisplayList(){
        List<CaseComment> displayList;
        displayList = [SELECT CommentBody from CaseComment where parentid =: CaseId and IsPublished=true];
        
        if(displayList != null && displayList.size() > 0 ){
            return displayList;
        }
        return null;
    }
}


Add this page in Case detail page.