+ Start a Discussion
Kishan Kumar 77Kishan Kumar 77 

I need to write a trigger that rejects double assignment of teachers.

I have an object as teacher_student__c .Whenever a student is linked to a teacher, check whether the student already has a teacher with same subject assigned to him/her and if already exists, then throw an error 'A teacher is already assigned to this student for the subject.
ANUTEJANUTEJ (Salesforce Developers) 
Hi Kishan,

Could you elaborate the scenario along with background details to check further and also it would be helpful if you could give an example to the scenario.

Looking forward for your response.

Regards,
Anutej
Kishan Kumar 77Kishan Kumar 77
Hey Anuj,
Basically I have 3 objects. Student__c, Teacher__c and Teacher_Student__c where the third object is the junction object. Now I need to write a trigger where Teacher_Student__c is the sObject. Now the condition is as I've mentioned above Whenever a student is linked to a teacher, check whether the student already has a teacher with same subject assigned to him/her and if already exists, then throw an error 'A teacher is already assigned to this student for the subject.
Jason ShrummJason Shrumm
Found Modules 5 and 6 on Creating triggers, but it explains how to reject dowble bookings of speakers. I need a trigger rejecting double assignment topics taken from https://essaydune.com/do-my-assignment/ for the same class.