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
SainSain 

I have to count a child records on parent object by using trigger

Hi All,

I have a two objects like doctor(parent) and patient(child), my scenario is i have to count a child records on parent object by using trigger.

(using rollup summary we can achieve this but i have to achieve with trigger)

please any one help me with code for this scenario.

Thanks in advance!!!
Best Answer chosen by Sain
sweetzsweetz

All Answers

sweetzsweetz
This was selected as the best answer
Deepak Kumar ShyoranDeepak Kumar Shyoran
Then you need to write a trigger on child object which will update it's parent field which hold the count for the child every time when a new child is created/updated/deleted/undeleted

This will update corresponding parent from the child records every time when an event is fired on child object.