+ Start a Discussion

Sum of Child object formula field on Parent Parent object number fieldn using trigger

Hi Everyone,

I have two custom objects.. one is Claim__c(Master) and other is Labour_cost__c(Child).
I have a formula field   Deprecition_amount__c on Labour_cost__c and one number field   Depreciation_Reimbursed__c on Claim__c.

I want to calculate sum of Deprecition_amount__c  which will display sum on Depreciation_Reimbursed__c on Claim__c  for each record.

Thanks in Advance.......
If you have a Master-Detail relationship between Claim__c and Labour_Cost__c, then you can create a "Roll-up summary field" on Master object (Claim__c) which will give you sum of  Deprecition_amount__c field values of all related Labour_Cost__c records.
(No need to write Trigger, and this is Salesforce Best practice)

If you have lookup field, change it to Master-Details field type.

Mark this as Best Answer, if this solves your problem.
Hi mritzi,

u r right but.... it calculate its value on the basis of other field : Part_cost__c, if first time we enter value in Part_cost__c it add the value,if value is less than previous value then add on the basis of this value