function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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.
Arthur SimonsArthur Simons
It amazes me that this community is so friendly and offers so many answers. Thanks a lot guys!
David WatkinsDavid Watkins
For me this is also amazing, besides I'm not tech savvy so I prefer to use sources like https://sunnypapers.com/paper-samples/technology/ that help with homework for students and school children. For me it has saved me many times because sometimes I have no muse or mood to write something, but from here you can find a lot of paper samples like the subject of technology that will help you with writing.