You need to sign in to do that
Don't have an account?
How to get custom child objects using standardcontroller ?
Hi,
I have two custom objects Blog & Comments, for each Comment, there is a parent Blog. So I have create a custom field of type Master-Detail Relationship for Comments object with field name Blog_Post and relation ship name Comment_r .
Now I want to show a Blog post and its associated comments in a page. It is showing error while I am try to get all the comments for a blog post. The code used as follows:
<apex:page showHeader="false" standardcontroller="Blog__c"> <apex:repeat value="{!Blog__c.Comment__r}" var="comment"> <div> <label>{!comment.Comment_User__c} <small>( <apex:outputText value="{0,date, EEE MMM d yyyy h:mm a}"> <apex:param value="{!comment.Comment_date__c}" /> </apex:outputText> )</small> </label> <br /><br /> <p>{!comment.Comment_text__c}</p> <br /> </div> </apex:repeat> </apex:page>
I got the error as follows
Description Resource Path Location Type
Save error: Invalid field Comment__r for SObject Blog_Post__c blogview.page /Blog/src/pages line 0 Force.com
How can I show the blog with its comments?
Please share the Function also where u query the data ....:)
Hi SFDC_Evolve,
Thanks for your replay. I didn't use any fuctions or custom controller to query the data. I have used the standaredcontroller for my custom object Blog_Post__c. I am try to get the comments through relationship.
Are you sure the relationship name is comment__r? Not comments__r ?
Kindly mark the answer as Best Solution if it helped you :)
I am giving example for contacts.
Hope this helps.
Greetings to you!
You need to add an extension to get the child on the parent object.
Here Contact is parent and Site_visit1__c is the child.
=================================================================================================
================================================================================================================================
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
www.kdeepali.com