+ Start a Discussion
billgreenhawbillgreenhaw 

Relatedlist - CaseComments not working (Trying to make tabbedCases)

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

Code:
<apex:page standardController="Case" showHeader="true" tabStyle="case" >
    <style> 
    .activeTab {background-color: #B7A752; color:white; background-image:none} 
    .inactiveTab { background-color: lightgrey; color:black; background-image:none} 
    </style>
   <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>
      <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
         <apex:relatedList subject="{!case}" list="OpenActivities" />
      </apex:tab>
         <apex:tab label="Activity History" name="ActivityHistory" id="tabActHis">
      <apex:relatedList subject="{!case}" list="ActivityHistories" />
      </apex:tab>
         <apex:tab label="Case Comments" name="CaseComments" id="tabCaseComments">
      <apex:relatedList subject="{!case}" list="CaseComments" />
      </apex:tab>
   </apex:tabPanel>
</apex:page>

 
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
TehNrdTehNrd
Try "CaseComment", not plural. It looks right but wouldn't hurt trying.


Message Edited by TehNrd on 07-15-2008 03:45 PM
jhennyjhenny
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?
insanedukeposseinsanedukeposse
Bueller? Anyone figure this out?
TLFTLF
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" />
</apex:page>

 

 

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?

 

bryan.gilbertbryan.gilbert

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

 

http://boards.developerforce.com/t5/Visualforce-Development/CaseComment-related-list/td-p/129629

 

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:pageBlock>   
    
    <apex:pageBlock>
        <apex:pageBlockTable value="{!case.casecomments}" var="c">
            <apex:column value="{!c.commentbody}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
    
</apex:page>

 

 

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:

 

http://boards.developerforce.com/t5/Visualforce-Development/How-Do-You-Figure-Out-Related-List-Names/td-p/80645

 

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

 

 

bryan.gilbertbryan.gilbert

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>
            </apex:pageBlockButtons>
            <table border="0"  class="commentsTable">       
            <tr>
                <th class="commentsActionColumn">Action</th>
                <th class="commentBodyClass">Comments</th>
            </tr>
            <!-- get the case comments from the controller -->
            <apex:repeat value="{!comments}" var="c">
                <tr>
                <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> 
                </td>
                <td>
                <!-- display the case comment formatted using the apex outputField -->
                <div class="commentTdClass">
                <apex:outputField value="{!c.commentbody}"></apex:outputField>
                </div>
                </td>
                </tr>
            </apex:repeat>
            </table>
        </apex:pageBlock>
    </apex:form>
</apex:tab>

 

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)?

 

TLFTLF

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