You need to sign in to do that
Don't have an account?
sriram anil
How to handle Compile Error: Invalid field Doctor__c for SObject Patient__c
This my apexclass:
------------------------------
Public class CreateMultiplePatients{
ID DoctorID;
public Doctor__c docObj{get;set;}
public List<Patient__c> multiplePatients{get;set;}
public CreateMultiplePatients(ApexPages.StandardController varName){
multiplePatients = New List<Patient__c>();
DoctorID = apexpages.currentpage().getparameters().get('id');
docObj = [SELECT id,name,Address__c,daysworking__c,Salary__c,Joining_Year__c,specialization__c FROM Doctor__c where id=:DoctorID];
Patient__c newpatient = New Patient__c();
multiplePatients.add(newpatient);
}
public void addRow(){
Patient__c newpatient = New Patient__c();
multiplePatients.add(newpatient);
}
public void saveMultiplepatients(){
for(integer i=0;i<multiplePatients.size();i++){
/ multiplePatients[i].Doctor__c =DoctorID;
}
insert multiplePatients;
}
}
------------------------------
Public class CreateMultiplePatients{
ID DoctorID;
public Doctor__c docObj{get;set;}
public List<Patient__c> multiplePatients{get;set;}
public CreateMultiplePatients(ApexPages.StandardController varName){
multiplePatients = New List<Patient__c>();
DoctorID = apexpages.currentpage().getparameters().get('id');
docObj = [SELECT id,name,Address__c,daysworking__c,Salary__c,Joining_Year__c,specialization__c FROM Doctor__c where id=:DoctorID];
Patient__c newpatient = New Patient__c();
multiplePatients.add(newpatient);
}
public void addRow(){
Patient__c newpatient = New Patient__c();
multiplePatients.add(newpatient);
}
public void saveMultiplepatients(){
for(integer i=0;i<multiplePatients.size();i++){
/ multiplePatients[i].Doctor__c =DoctorID;
}
insert multiplePatients;
}
}
All Answers
Hi Anil,
This error is due to below code:
multiplePatients[i].Doctor__c =DoctorID;
It seems that you are uopdating field Doctor__c which is not available
this program used to
i am creating button in doctor obj---Vf page button link
doctor is parent
patient is child
the doctor obj by using button create multiple patients