-
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
Use Salesforce Implementation Consultants to Get your Business CRM Up and Running by 2023.
The top companies of today are increasing their the profits of their business by adopting an all-encompassing strategy for Salesforce CRM. Salesforce, the best CRM system,…
3 Ways Salesforce is Driving the EdTech Industry in 2023
Salesforce is a cloud-based customer relationship management (CRM) platform that is driving several technology trends in education. The company’s products are used by millions of…
4 Financial Service Trends for Businesses and FSIs | Salesforce Financial Services Cloud
Digital adoption has increased in the past few years, especially across banking, insurance, and wealth management segments. It has shown a steady growth despite the…
Popular Salesforce Videos
Salesforce CPQ Subscription Pricing
Configure Price Quote (CPQ) is a powerful sales tool that enables companies to produce accurate and highly configured sales quotes for customers — especially in…
Winter '21 Release | Salesforce Tutorial Video
The Sandbox Preview window for Winter '21 begun on September 11, 2020. You must have an active sandbox on a preview instance before then to…
Salesforce On-Demand Administrator
Apphienz's On-demand Administrator delivers much more than the company's expectations. It is hands-on, makes the work easy, efficient and productive along with being available to…
Popular Salesforce Infographics
Unlock the Potential of Financial Services with Future Trends | Salesforce
The financial services industry is being transformed by emerging technologies like AI, Low-Code, No-Code Solutions, Adoption of the cloud. Discover the various future and trending…
Unlock Agile and Efficient Salesforce Testing With AI-Driven Tools
Like every industry, the world of software testing and quality assurance has also gone under massive development with the emergence of AI technology. Developers and…
CRM Predictions 2018
The coming year will be a stirring one for businesses, esp while talking about CRM technology. With the arrival of the prognosticating season, let’s quickly…