+ Start a Discussion
milan mohantymilan mohanty 

How to write trigger to count it's child?

I have a custom field on Account called CountChild__c, so now I want to write a trigger on Account to count it's related contacts and update that fild  CountChild__c, so if a Account will have 3 Contacts then that CountChild__c field on Account should be update with the value 3. How can I achove it through trigger? Please guide me. Thank you.
Vamsi KrishnaVamsi Krishna
first thing, you need to write the trigger on Contact object and not Account object..
next, there are heaps of blogs and previous solved answers with actual trigger code for the same purpose..

references :