+ Start a Discussion

Relatedlist - CaseComments not working (Trying to make tabbedCases)

I am trying to made tabbedCases (like the example tabbedAccounts).  Here is the code:

<apex:page standardController="Case" showHeader="true" tabStyle="case" >
    .activeTab {background-color: #B7A752; color:white; background-image:none} 
    .inactiveTab { background-color: lightgrey; color:black; background-image:none} 
   <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel"  tabClass="activeTab" inactiveTabClass="inactiveTab">
      <apex:tab label="Detail" name="CaseDetails" id="tabdetails">
         <apex:detail relatedList="true" title="true"/>
      <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
         <apex:relatedList subject="{!case}" list="OpenActivities" />
         <apex:tab label="Activity History" name="ActivityHistory" id="tabActHis">
      <apex:relatedList subject="{!case}" list="ActivityHistories" />
         <apex:tab label="Case Comments" name="CaseComments" id="tabCaseComments">
      <apex:relatedList subject="{!case}" list="CaseComments" />

I get the error: 'CaseComments' is not a valid child relationship name for entity Case.  This looks to be the correct name according to the WSDL.

Any thoughts?

Message Edited by billgreenhaw on 07-14-2008 02:18 PM
Try "CaseComment", not plural. It looks right but wouldn't hurt trying.

Message Edited by TehNrd on 07-15-2008 03:45 PM
I get this issue as well. Adding the related list to the page layout is supposed to fix,
but seems not to work for case comments related list.
Anyone figure it out?
Bueller? Anyone figure this out?
I too am trying to add the CaseComments related list to one of my Visualforce pages. I get the following error:


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


Here is my Visualforce and associated controller extension:



<apex:page standardController="Case" extensions="ProjectControllerExt" >
<apex:relatedList list="CaseComments" />



public with sharing class ProjectControllerExt {

public Case project { get; set; }

public ApexPages.StandardController con { get; set; }

public ProjectControllerExt(ApexPages.StandardController con) {
this.con = con;
this.project = (Case) con.getRecord();


Am I doing something wrong? Is anyone able to make this work?



I had the same problem and then I found this posting:




It says that we need to manaully insert the code to display the case comments.



<apex:page standardController="Case">
    <apex:pageBlock >
    You're looking at some related lists for {!case.casenumber}:
        <apex:pageBlockTable value="{!case.casecomments}" var="c">
            <apex:column value="{!c.commentbody}"/>



I do not like this soultion because we need to also create the code to enable normal actions such as edit and delete.  



Notice how the Account example only shows related lists that are simple tables!




Another related problem dealing with Custom Objects and related lists is discussed here:




It says that we need to make sure the custom objects related list is included on the default page layout.




Building custom apex code seems to be the only solution.   I suppose this is because CaseComment and EmailMessage are objects themselves so they are more complex then a simple related list.



<apex:tab label="Comments" name="Comments" id="tabComments">
    <apex:form >
        <apex:pageBlock id="commentsPageBlock">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Toggle Sort" action="{!RequeryComments}" id="theButton" rerender="commentsPageBlock"></apex:commandButton>
            <table border="0"  class="commentsTable">       
                <th class="commentsActionColumn">Action</th>
                <th class="commentBodyClass">Comments</th>
            <!-- get the case comments from the controller -->
            <apex:repeat value="{!comments}" var="c">
                <td class="commentsActionColumn">
                <!-- open the case comment for edit -->
                <apex:outputLink title="" value="/{!c.id}/e?parent_id={!c.parentId}&retURL=/apex/{!$CurrentPage.Name}%3Fid={!case.id}" style="font-weight:bold">Edit</apex:outputLink> 
                <!-- display the case comment formatted using the apex outputField -->
                <div class="commentTdClass">
                <apex:outputField value="{!c.commentbody}"></apex:outputField>


The above includes the code for the Edit action but it doesn't work if the user can not edit a given case comment (e.g. they did not create the comment or have modify all privledges on CaseComment).  I'm looking for a solution to that problem. Specifically;  


Does anyone know how to only render based on record level security (sometimes called row level security)?



I believe all that is required is to specify the "with sharing" keywords on your controller class definition.