-
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
Understanding sObjects in Salesforce: A Comprehensive Guide
Introduction In the realm of Salesforce, sObjects play a crucial role in managing and manipulating data. Short for "Salesforce Objects," sObjects are the fundamental data…
Custom CPQ Solution- Need of The Hour for Manufacturing Firms
Personalizing Salesforce CPQ to maximize ROI for Manufacturing Industries B2B customers are expecting the ease of use and intuitiveness of B2C shopping experiences. But the sales cycle…
7 Signs Your Company Needs a Salesforce Consulting Partner
1. Struggling with Salesforce Adoption One of the most common challenges businesses face is low adoption rates of Salesforce among their teams. Despite its powerful…
Popular Salesforce Videos
How to Connect to External Data | Salesforce
An external data source specifies how to access an external system. Salesforce Connect uses external data sources to access data that's stored outside your Salesforce…
Salesforce Trailhead - Get Started with the Salesforce Mobile App
After watching this video you'll be able to: Identify the flavors of the Salesforce mobile app available to you. Log in to your Salesforce org…
Getting started with salesforce
Salesforce is a customer relationship management solution that brings companies and customers together. It's one integrated CRM platform that gives all your departments — including…
Popular Salesforce Infographics
Why Integrate Your Pardot Account with Salesforce?
Salesforce Sales Cloud is primarily a sales tool while Pardot is a marketing automation platform. Both are designed to increase sales and maximize efficiency for…
Success With Salesforce For Full Cycle Reps
I am presenting this infographic to help full cycle sales reps get the most out of salesforce and their Sales Engagement platform.
Sales Productivity: Tips to Overcome Productivity Challenges
Growing sales is the cornerstone of business success. Whether you're a startup or an established enterprise, the objective remains the same: Increase Revenue, Expand your…