Надо создать Vfp и Alex controller. Нужно фильтровать записи в таблице по “Doctor” и отображать часы приема выбранного доктора в WorkingHoursStart и WorkingHoursEnd.
Вот пример моего кода:
<apex:page id=“Hospital” controller=“HospitalController”>
<apex:form >
<apex:pageBlock title=“Appointments Table”>
<apex:pageMessages />
<apex:pageBlockSection columns="1">
<apex:actionFunction action="{!getapps}" name="selectDoctor" rerender="TableApp"/>
<apex:selectList value="{!app.Doctor__c}" size="1" multiselect="false" onchange="selectDoctor();">
<apex:selectOptions value="{!selectValues}"/>
</apex:selectList>
<apex:outputLink value="https://vrpconsulting-1ba-dev-ed.lightning.force.com/lightning/o/Doctor__c/new?count=1&nooverride=1&useRecordTypeCheck=1&navigationLocation=LIST_VIEW&uid=162678961157937739&backgroundContext=%2Flightning%2Fo%2FDoctor__c%2Flist%3FfilterName%3DRecent">Add New Doctor</apex:outputLink>
<apex:outputField value="{!app.Doctor__c}" label="Working Hours Start"/>
<apex:outputField value="{!app.Doctor__c}" label="Working Hours End"/>
<apex:inputField value="{!app.Patient__c}" />
<apex:outputLink value="https://vrpconsulting-1ba-dev-ed.lightning.force.com/lightning/o/Patient__c/new?count=2&nooverride=1&useRecordTypeCheck=1&navigationLocation=LIST_VIEW&uid=162679076452576594&backgroundContext=%2Flightning%2Fo%2FPatient__c%2Flist%3FfilterName%3DRecent">Add New Patient</apex:outputLink>
<apex:inputField value="{!app.AppointmentDate__c}" />
<apex:inputText value="{!app.Duration__c}" />
<apex:commandButton action="{!saveaction}" value="Add new Appointment"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!apps}" var="d" id="TableApp">
<apex:column headerValue="Action">
<apex:outputLink value="{!'/'&d.Doctor__c}">View</apex:outputLink>
</apex:column>
<apex:column value="{!d.Doctor__c}"/>
<apex:column value="{!d.Patient__c}"/>
<apex:column value="{!d.AppointmentDate__c}"/>
<apex:column value="{!d.Duration__c}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!previous}" value="previous" rerender="TableApp"/>
<apex:commandButton action="{!next}" value="next" rerender="TableApp"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
и ApexController:
public with sharing class HospitalController {
public Appointment__c app{get; set;}
public List<Doctor__c> docInf{get; set;}
public List<Appointment__c> appointments{get; set;}
public String appointmentId{get; set;}
public String selectedvalue{get; set;}
private integer totalResc = 0;
private integer index = 0;
private integer blockSize = 5;
public HospitalController(){
app = new Appointment__c();
docInf = getdocInf();
totalResc = [select count() from Appointment__c];
}
public List<Appointment__c> getapps(){
List<Appointment__c> apps = [SELECT Name, Doctor__c, Patient__c, AppointmentDate__c, Duration__c FROM Appointment__c LIMIT:blockSize OFFSET:index];
return apps;
}
private List<Doctor__c> getdocInf(){
List<Doctor__c> listDoctors = [SELECT Id, Name, WorkingHoursEnd__c, WorkingHoursStart__c FROM Doctor__c];
return listDoctors;
}
public void information(){
appointments = [SELECT Id, Doctor__c, Patient__c, AppointmentDate__c, Duration__c FROM Appointment__c WHERE Doctor__c = :appointmentId];
}
public void saveaction(){
system.debug('saveaction inside===>'+ app);
insert app;
if(app.ID !=null){
Apexpages.addMessage(new ApexPages.message(ApexPages.Severity.INFO, 'Record saves successfully. Please reload page'));
}
}
public void previous(){
index = index - blockSize;
}
public void next(){
index = index + blockSize;
}
public boolean getprev(){
if(index == 0)
return true;
else
return false;
}
public boolean getnxt(){
if((index + blockSize) > totalResc)
return true;
else
return false;
}
public List<SelectOption> getselectValues(){
List<SelectOption> lOptions = new List<SelectOption>();
for (Doctor__c d : docInf){
lOptions.add(new SelectOption(d.Id, d.Name));
}
return lOptions;
}
}
База: