Appointment: API Name Appointment__c
Doctor: API Name Doctors__c
I am trying to list all the records of the selected doctor
public class AppointmentsController {
private List<Doctors__c>doctorList = new List<Doctors__c>();
private List<Patient__c>patientList = new List<Patient__c>();
private List<Appointment__c>appointmentList = new List<Appointment__c>();
public Doctors__c selectedDoctor {get;set;}
public Patient__c selectedPatient {get;set;}
public List<Appointment__c>doctorAppointmentsList{get;set;}
public DateTime appointmentDate {
get{
return appointmentDate;
}
set;
}
public Id selectedDoctorId{
get;
set{
selectedDoctorId=value;
updateDoctor();
updateAppointments();
}
}
public AppointmentsController (){
newAppointment=new Appointment__c();
patientList =[SELECT Id,Name FROM Patient__c ORDER BY Name ASC];
doctorList = [SELECT Id,Name,Working_Hours_Start__c,Working_Hours_End__c FROM Doctors__c ORDER BY Name ASC];
appointmentList=[SELECT Id,Name,Doctor__c,Appointment_Date__c,Duration_in_minutes__c,Patient__c FROM Appointment__c ORDER BY Name ASC];
selectedDoctor = doctorList[0];
selectedPatient= patientList[0];
}
private void updateAppointments()
{
for(Appointment__c appointment : appointmentList) {
if(selectedDoctorId==appointment.Doctor__c.Id)
{
doctorAppointmentsList.add(appointment);
}
}
}
private void updateDoctor()
{
for(Doctors__c doctor : doctorList) {
if(this.selectedDoctorId==doctor.Id)
{
selectedDoctor=doctor;
}
}
}
updateAppointments() error in this function