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
jai.sjai.s 

Trigger to update sum of Child records into Parent object Custom Field

Hi,

I have scenario that update a custom field(Amount__c) of parent(Account) with sum of all child records (Total_Price__c) from Child Object(Invoice Line Item).

I have to wirte a trigger for above scenario, if any one have sample code please share it.

Thanks in advance,
Shaik
Suneel#8Suneel#8
If both the objects are related through Master Detail relationship, create a field of type Roll up Summary on the parent object
Sai Ram ASai Ram A

you may take a look at Anthony Victorio's generic solution:
1. http://www.anthonyvictorio.com/salesforce/roll-up-summary-utility/
2. Optional: https://developer.salesforce.com/forums/ForumsMain?id=906F00000008yWuIAI

I've used this a few times and its a great solution.  

Thanks
BLearn