-
How to get child object records by check the checkbox of parent record
Hello everyone I am new to salesforce. Strucked in one task please help me. My task is to get related student reports(Child object) by clicking the checkbox of student name(parent object). My code is given below:
VFpage:<apex:page controller="SelCheckBox_cntrl" sidebar="false">
<apex:form >
<apex:pageBlock title="Select Student Name">
<apex:SelectCheckboxes value="{!coolbool}">
<apex:SelectOptions value="{!StudentNames}"/>
<apex:actionSupport event="onclick" reRender="messagebox"/>
</apex:SelectCheckboxes>
</apex:pageBlock>
<apex:pageBlock title="Related Selected Reports">
<apex:pageBlockTable value="{!srep}" var="SR">
<apex:column value="{!SR.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:commandButton value="Get Selected Reports" action="{!selctedReports}"/>
</apex:form>
</apex:page>APEX Code:
public class SelCheckBox_cntrl {
public String StudentDetails{set;get;}
public List<Student_Reports__c> srep{set;get;}
public Boolean coolbool{set;get;}public SelCheckBox_cntrl(){
srep = new List<Student_Reports__c>();
coolbool = false;
}public List<SelectOption> getStudentNames(){
List<SelectOption> Sel = new List<SelectOption>();
for(Student_Details__c SD : [Select id,Name from Student_Details__c]){
Sel.add(new SelectOption(SD.id,SD.Name));
}
return Sel;
}public void selctedReports(){
if(coolbool==true){
srep = [Select id,Name,Student_Name__c,Test1__c,Test2__c,Test3__c,Certification__c,Result__c from Student_Reports__c where Student_Name__c=:StudentDetails];
}
else{
system.debug('ERROR: Select any Name');
}
}
}Please correct the code
Thanks in advance
Log In to reply.
Popular Salesforce Blogs
6 Leading Salesforce Trends for 2022 and Beyond
Salesforce unifies the modalities of numerous departments—marketing, services, sales, and customer management—and accelerates harmonious coordination between diverse company lines in the new hybrid-work paradigm. It…
What Slack and Salesforce Sales Cloud Could Do for Your Business
Today’s customers no longer prefer emails and phone calls. Customers anticipate continuous vendor assistance and participation. This means that reps must spend more time building…
No Code Heroku And Salesforce Integration
Heroku enables organizations/developers to build, run, and operate applications entirely in the cloud using several different languages. Heroku is a fully managed PaaS, which means…
Popular Salesforce Videos
What is Billing - Salesforce Revenue Cloud
How can you transform your billing system for subscription and usage models? By dropping your legacy systems and streamlining your processes. In this video, learn…
Is Salesforce A Good Career For Freshers?
Wondering whether Salesforce is a good career for freshers or not? Here are all your answers. Join this useful group for Salesforce job & career…
Salesforce Pardot: 2020 Update
If you’re a current Salesforce user, you may be hearing a lot about Pardot these days. Perhaps you are using MailChimp, Campaign Monitor, or Constant…
Popular Salesforce Infographics
Your Guide to Salesforce Certifications
In the age of customer experience, businesses now rely on their CRM systems more than ever. As the world leader in CRM software, Salesforce knows…
Benefits of Salesforce Pardot Implementation
Cyntexa offers the best Salesforce Pardot Implementation services so that you can offer the best customer services. Our certified experts will provide Salesforce Pardot Implementation…
Top Salesforce Acquisitions Of All Time and In 2020
Salesforce has been on a shopping spree over the last few years. We all read quite frequently about Salesforce acquisitions. They are quick enough to…