You need to sign in to do that
Don't have an account?
Admin 123
To display sum of all contact for its respective Account in its Parent Account.
Account and Contact Object have Lookup relationship.
The Requirement is:
ParentAccount: ABC has
Account1: Contact1, Contact2 (count of contact in account will display 2 in Account custom field)
ParentAcc: ABC has
Account2: Contact1, Contact2, Contact3(count of contact in account will display 3 in Account custom field)
But now In Parent Account(in its custom field): ABC Count Should Display as 5.
How can this be achieved through Apex code?
The Requirement is:
ParentAccount: ABC has
Account1: Contact1, Contact2 (count of contact in account will display 2 in Account custom field)
ParentAcc: ABC has
Account2: Contact1, Contact2, Contact3(count of contact in account will display 3 in Account custom field)
But now In Parent Account(in its custom field): ABC Count Should Display as 5.
How can this be achieved through Apex code?
You need to write a trigger on contact on After insert and after update and before delete events
Thanks ,
Raj
1) First make a field on Account Named Total_Contacts__c
2) Write / Copy Paste a following trigger on Contact object.
Trigger Code:
Hopr this helps!
Hope this helps!