0

have a Visual force page that overrides the "Close Case button" on case details page.VF page uses case standardController.I want to populate CaseComment.commentbody field of the from this VF page. CaseComment is a Child object of Case.Sample code is as below

<apex:page standardController="Case"> <apex:form> <apex:inputField value="{!Case.Postback_Options__c}" /> <apex:inputField value="{!CaseComment.CommentBody}" label="Internal Comments" /> </apex:form> </apex:page>

This throws an error Unknown property 'CaseStandardController.CaseComment'

Can Somebody please help me out.

1
  • Seems like you have missed the code. edit the question and add it
    – highfive
    Commented Mar 25, 2014 at 6:38

2 Answers 2

1

CaseComment is separate object in salesforce. So I suggest you use either standard controller extension or custom controller.

But If you want or have to use only standard controller here is some code:

<apex:page standardController="Case">
   <apex:form>
       <apex:repeat value="{!Case.CaseComments}" var = "cc">
           <apex:inputField value="{!cc.CommentBody}" label="Internal Comments" />
       </apex:repeat>
   </apex:form>
</apex:page> 
0

<apex:inputField> can only be used with SObject fields as per the documentation. Your Case.CaseComments returning a List. So you have to iterate through the list to access child fields.

<apex:repeat value="{!Case.CaseComments}" var = "child">
    <apex:inputField value="{!child.CommentBody}" label="Internal Comments" />
</apex:repeat>

NOTE: Make sure to check the child relationship name in the WSDL for safe side.

4
  • I want to insert CaseComment.CommentBody ,not just iterate through them
    – user7533
    Commented Mar 25, 2014 at 9:09
  • In that case it's better to go for a custom controller. Because later on also you may need to include some logic.
    – highfive
    Commented Mar 25, 2014 at 9:22
  • Yes . developing a custom Controller works
    – user7533
    Commented Mar 31, 2014 at 9:06
  • Cool! It's better to having a custom controller for a frequently accessing page because those are having a higher possibility of requirement change :)
    – highfive
    Commented Mar 31, 2014 at 12:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .