You need to sign in to do that
Don't have an account?

Trigger For a doctor to not having more than 8 appointments in a day
I have a scenario where a dcotor cannot have more than 8 appointments in a day. I need to write a trigger on Appointment. I have three custom object Patient,Docator and appointment. Appointment have a lookup of both patient and doctor.
- I assume the trigger will be before insert/update
- Find the doctor from the appointment record in the trigger.
- Do a Aggregate Query on Appointment object, group by doctor, for the given day. Loop through the results to find out the existing number of appointment for the doctor. If it is equal to 8, then throw error, else continue.
I hope this makes sense.Hi Amit,
I am new to salesforce. Can you help me in writing the code.
Thanks
I am not able to do a Aggregate Query on Appointment object, group by doctor, for the given day. Loop through the results to find out the existing number of appointment for the doctor. If it is equal to 8, then throw error, else continue.
Can you please ellobrate this.It will be helpful for me.