Добрый день, столкнулся с проблемой, пытаюсь добавить новую запись в таблицу в которой есть связанные поля.
Appointment__c ac = new Appointment__c();
ac.Duration_in_minutes__c = newDuration;
ac.Appointment_Date__c = newDate;
ac.Doctor__r.Name = selectDoctor;
Картинка с табами и их связями https://drive.google.com/file/d/1ei7_XuUM57M-z0b1Isn7PFjNHVetAJ8q/view?usp=sharing
Всё работает если убрать поле с добавлением имени доктора.
Appointment__c ac = new Appointment__c();
ac.Duration_in_minutes__c = newDuration;
ac.Appointment_Date__c = newDate;
ac.Doctor__r = new Doctor__c();
ac.Doctor__r.Name = selectDoctor;
Всё было так просто.
Я конечно так пытался через insert , но тоже не получалось.
insert new Appointment__c(Duration_in_minutes__c = newDuration, Appointment_Date__c = newDate, Doctor__r = Doctor__c(Name = selectDoctor), Patient__r = new Patient__c(Name = selectPatient));
Спасибо огромное!
insert new Appointment__c(
Duration_in_minutes__c = newDuration,
Appointment_Date__c = newDate,
Doctor__r = Doctor__c(Name = selectDoctor),
Patient__r = new Patient__c(Name = selectPatient)
);
должно быть
insert new Appointment__c(
Duration_in_minutes__c = newDuration,
Appointment_Date__c = newDate,
Doctor__r = new Doctor__c(Name = selectDoctor),
Patient__r = new Patient__c(Name = selectPatient)
);
и
selectedDoctorName, selectedPatientName
но блин, обычно используют Id. Почему имена?