I am trying to put visualforce page on a custom object's standard page layout. I want to display all the courses that have been assigned to the student. I have three custom objects Student, StudentCourseDtlAssc, and Course Detail. I want to display the courses that the student is taking on the Student page layout. Course Detail have information about the course such as name, time, room, etc. StudentCourseDtlAssc is a junction object between student and course detail. Course Detail and StudentCourseDtlAssc have a Master-Detail Relationship. StudentCourseDtlAssc and Student has a lookup relationship.
Controller Code:
public class StudentCourseList {
private ApexPages.StandardController controller {get; set;}
private Students__c s;
public StudentCourseList(ApexPages.StandardController controller){
this.controller = controller;
this.s = (Students__c)controller.getRecord();
}
public List<StudentCourseDtlAssc__c> CourseDetails;
public List<StudentCourseDtlAssc__c> getCourseDetails(){
List<StudentCourseDtlAssc__c> courses = Database.query(
'SELECT StudentCourseDtlAsscs__c.Course_Detail__r.FKCourse__r.Name,' +
'StudentCourseDtlAsscs__c.Course_Detail__r.DOW_Abbr__c,StudentCourseDtlAsscs__c.Course_Detail__r.Professor__c,StudentCourseDtlAsscs__c.Course_Detail__r.FKCourse__r.Name' +
'StudentCourseDtlAsscs__c.Course_Detail__r.StartDate__c FROM StudentCourseDtlAssc__c');
return courses;
}
}
Visualforce Page:
<apex:page standardController="Students__c" extensions="StudentCourseList">
<apex:form >
<apex:pageBlock title="Student Schedule" id="student_schedule">
<apex:pageBlockTable value="{!CourseDetails}" var="st">
<apex:column value="{!st.Course_Detail__r.FKCourse__r.Name}"/>
<apex:column value="{!st.Course_Detail__r.Professor__c}"/>
<apex:column value="{!st.Course_Detail__r.FKRoom__r.Name}"/>
<apex:column value="{!st.Course_Detail__r.DOW_Abbr__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
I am getting the following error:
Content cannot be displayed: Didn't understand relationship 'StudentCourseDtlAsscs__c' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
I tried replacing 'StudentCourseDtlAsscs__c
' to 'StudentCourseDtlAsscs__r
', but I still get a similar error.
Am I headed in the right direction? If so, how do I solve this? Is there another way?
StudentCourseDtlAsscs__c
with__r
?