-
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
How Salesforce Can Benefit Real Estate Business?
As a real estate agent, your primary goal is to close deals quickly while providing outstanding customer service. However, with a never-ending stream of leads…
Learn Salesforce Einstein – Chapter 8 (Training – Create Model)
Go to the Dataset Detail page. Here click on Create Model button. It will open a new page asking for Model Name. Fill the name here…
Salesforce User Authentication : Two Factor Authentication
User Authentication a process to authorize someone to access specific resources. Username and password we generally used for authentication purpose but in the advanced world of…
Popular Salesforce Videos
The Future of Salesforce App Dev with Parker Harris & Friends
Join Parker Harris, Salesforce product managers, and engineers as we kick off Day 2 of TrailheaDX with an in-depth look at exciting new features coming…
Salesforce Einstein Analytics for Developers
Einstein Analytics is the Salesforce-native analytics platform, providing users with insights into their business. This session dives into topics including APIs, metadata, packaging, and other…
MailChimp Salesforce Integration
The MailChimp and Salesforce integration allow you to start creating email campaigns from the leads and contacts in your Salesforce CRM. With the integration, it becomes easy to create list segmentation…
Popular Salesforce Infographics
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…
6 Steps to Take When Searching For a CRM Platform
One CRM platform may have excellent event tracking, which means you can learn what a specific visitor does on your website, from which pages they…
Salesforce – A Key For Your Industry Solutions
Salesforce endlessly improves the productivity and performance of the company. To enhance the customer experience and generate more revenue in 2018 many industries will be…