function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
_alex23_alex23 

Vf page combining values from multiple related objects

Hi there, 

I need to create a custom Visualforce page which would display school’s transcript in the following way: 

Name: John Smith (field on Contact object)
Student ID: 1234 (field on Contact object)
Program Enrollment: High School / Middle School / Elementary School (picklist based on what program the contact is enrolled in) (Program enrollment object, lookup with Contact)
Cumulative GPA: (3.90) (Program enrollment object)

followed by a set of tables (that should be rendered based on the Program Enrollment selection): 


H1: Term: Q3 2020 (Term registration object., lookup with Contact)
H2: Semester GPA: 3.5 (Term registration object)
Course | Grade | Earned Credits
ENG10  |    A.    |      2
Math10 |    B.     |      3

(course grades and info comes from Course enrollment object, lookup with Term registration)

Please let me know what direction to go with it. I’m pretty new to Visualforce and this is a bit overwhelming. Thank you. 
Abhishek BansalAbhishek Bansal
Hi Alex,

You can take help from the below link and get started with VF page. Once you have something ready we can suggest you the changes as per the issues that you are facing:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start.htm

Let me know if you need more help on this.

Thanks,
Abhishek Bansal.
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790
Phone: +917357512102
_alex23_alex23

Hi Abhishek,

Here is the way I'm going with it. I figured I need to create a custom controller and a wrapper class. 

//controller

public class transcriptPage {
 Public transcriptPage()
    {
    for(Contact con : [SELECT ID_Number__c, Name, id FROM Contact WHERE RecordTypeId = '0126g000000M6wbAAC'])
     {
        for(Term_Registration__c termReg : [SELECT id, Contact__c, GPA__c, Term__c, New_Student__c, Number_of_Units__c FROM Term_Registration__c])
          {
                for(hed__Course_Enrollment__c courseEnrol : [SELECT hed__Contact__r.Name,hed__Credits_Attempted__c, Credits_Earned__c, Drop_Date__c, Letter_Grade__c, Record_Status__c, Numerical_Grade__c FROM hed__Course_Enrollment__c WHERE RecordTypeId ='0126g000000szEsAAI'])
                {
                   WrapList.add(new WrapClass(con, termReg, courseEnrol));
                }
          }
     }
    }
    Public List<wrapClass> WrapList{get;set;}
        Public Class wrapClass{
            public Contact con {get;set;}
            public Term_Registration__c termReg{get;set;}
            public hed__Course_Enrollment__c courseEnrol{get;set;}
                Public wrapClass(Contact  tempCon , Term_Registration__c  tempTermReg, hed__Course_Enrollment__c  tempCourseEnrol)
                {
                con=tempCon; 
                termReg=tempTermReg; 
                courseEnrol=tempCourseEnrol; 
                } 
                             }
}
 

Here is the Visualforce page (just the basic table for now, to see if it works):

//VF page
<apex:page Controller="transcriptPage">
   
<Apex:form >

<apex:pageBlock >

    <apex:PageBlockTable value="{!WrapList}"  var="item" >

       <apex:column value="{!item.courseEnrol.hed__Contact__r.Name}"/>

       <apex:column value="{!item.courseEnrol.hed__Credits_Attempted__c}"/>

       <apex:column value="{!item.courseEnrol.Letter_Grade__c}"/>

   </Apex:PageBlockTable>

</apex:pageBlock>

</Apex:form>

</apex:page>

I get an error: 

System.LimitException: Too many SOQL queries: 101
Class.transcriptPage.<init>: line 6, column 1

which I assume can be solved (I'm very new so I might be wrong by passing the current record ID from URL to controller and somehow quering results only for one record (this is the goal). 

I couldn't yet figure out how to do that. 

I would really appreciate any help with that as well as feedback regarding the general direction of what I am trying to do. 

Thank you. 

_alex23_alex23

Update.

Controller: 
 

//custom controller

public class transcriptPage {
 Public transcriptPage()
    {
    String conId = ApexPages.currentPage().getParameters().get('id');
    for(Contact con : [SELECT ID_Number__c, Name, id FROM Contact WHERE RecordTypeId = '0126g000000M6wbAAC'AND Id = :conId ])
     {
        for(Term_Registration__c termReg : [SELECT id, Contact__c, GPA__c, Term__c, New_Student__c, Number_of_Units__c FROM Term_Registration__c])
          {
                for(hed__Course_Enrollment__c courseEnrol : [SELECT hed__Contact__r.Name,hed__Credits_Attempted__c, Credits_Earned__c, Drop_Date__c, Letter_Grade__c, Record_Status__c, Numerical_Grade__c FROM hed__Course_Enrollment__c WHERE RecordTypeId ='0126g000000szEsAAI'])
                {
                   WrapList.add(new WrapClass(con, termReg, courseEnrol));
                }
          }
     }
    }
    Public List<wrapClass> WrapList{get;set;}
        Public Class wrapClass{
            public Contact con {get;set;}
            public Term_Registration__c termReg{get;set;}
            public hed__Course_Enrollment__c courseEnrol{get;set;}
            Public wrapClass(Contact  tempCon , Term_Registration__c  tempTermReg, hed__Course_Enrollment__c  tempCourseEnrol)
                {
                con=tempCon; 
                termReg=tempTermReg; 
                courseEnrol=tempCourseEnrol; 
                } 
                             }
}
 
//VF Page

<apex:page Controller="transcriptPage">
   
<Apex:form >

<apex:pageBlock >

    <apex:PageBlockTable value="{!WrapList}"  var="item" >

       <apex:column headerValue="Name" value="{!item.con.Name}"/>

       <apex:column headerValue="Attempted Credits" value="{!item.courseEnrol.hed__Credits_Attempted__c}"/>

       <apex:column headerValue="Letter Grade" value="{!item.courseEnrol.Letter_Grade__c}"/>

   </Apex:PageBlockTable>

</apex:pageBlock>

</Apex:form>

</apex:page>

Syntax seems to be correct, but no data is returned. 

 

User-added image

I would really appreciate any recommendations as I am not sure where the problem is. I suspect that somehow my controller doesn't store the data, debugging gave me the following error: "Inner types are not allowed to have inner types". I don't know how to interpret it at all. 

 

Brodie MatsonBrodie Matson
There are innumerable sites on the web that can help you in finding an appropriate house as per your date of birth. You can likewise visit https://topeduservices.com/ for vastu standards on youtube to find support. Much obliged to you for offering such an astounding theme to us.