You need to sign in to do that
Don't have an account?

Display Parent's child records when selected in lookup
I have a requirement where the vf page should display parent's child record when searched from lookup. TO be precise, there are three objects. Class, Students and Attendance tracker.
Class is the parent of both of these objects. When class record is searched from attendance lookup, students records should display.
Below is my code.
vf page
I have managed till displaying lookup on page but i cannot able to display button which pulls student's records. Please review this and help me in achieivng the above mentioned scenario.
Thank you in advance
Sastri
Class is the parent of both of these objects. When class record is searched from attendance lookup, students records should display.
Below is my code.
public class AttendenceController { public Class__C selectedUser { get; set; } public student__c stu {get; set;} public string recid{get;set;} public List<Attendance_Tracker__c> contacts {get; set;} public class StudentWrapper { public Student__c student {get; set;} public Boolean absent {get; set;} public StudentWrapper() { this.absent = false; } public StudentWrapper(Student__c student) { this(); this.student = student; } } public List<StudentWrapper> students {get; set;} Date day = Date.today(); public AttendenceController() { students = new List<StudentWrapper>(); for (Student__c student : [select Name, Class__c from Student__c WHERE Class__C!= Null]) { students.add(new StudentWrapper(student)); } } public PageReference submit() { List<Attendance_Tracker__c> attendance = new List<Attendance_Tracker__c>(); for (StudentWrapper wrapper : this.students) { attendance.add(new Attendance_Tracker__c( Date__c = this.day, Student__c = wrapper.student.Id, Present_Today__c = wrapper.absent, Class_del__c = wrapper.student.Class__c )); } if (!attendance.isEmpty()) { insert attendance; } return null; } public Attendance_Tracker__c getCurrentAccount(){ return [Select Id, Class_del__c from Attendance_Tracker__c limit 1]; } }
vf page
<apex:page controller="AttendenceController"> <apex:form > <apex:pageBlock > <b> Select Class:</b> <apex:inputField required="true" value="{!CurrentAccount.Class_del__c}"/> <apex:pageBlockTable value="{!students}" var="wrapper"> <apex:column value="{!wrapper.student.Name}" /> <apex:column > <apex:facet name="header">Present Today</apex:facet> <apex:inputCheckbox value="{!wrapper.absent}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:commandButton action="{!submit}" value="Submit" onComplete="window.location.reload();"/> </apex:form> </apex:page>
I have managed till displaying lookup on page but i cannot able to display button which pulls student's records. Please review this and help me in achieivng the above mentioned scenario.
Thank you in advance
Sastri