You need to sign in to do that
Don't have an account?
Vempally
Required Trigger on child accessing parent field and updating parent.
Hi Everyone,
Can anyone give the code and explanation where i need to udate parent field with the value calculated with child fields.
Eg: Rollup Summary for Sum(). Need trigger code fro this for understanding.
Can anyone give the code and explanation where i need to udate parent field with the value calculated with child fields.
Eg: Rollup Summary for Sum(). Need trigger code fro this for understanding.
Option 1:- Process builder
1) https://developer.salesforce.com/forums/?id=906F0000000BHvJIAW
2) https://developer.salesforce.com/forums/?id=906F0000000B2C0IAK
Option 2:- Trigger
1) https://developer.salesforce.com/forums/?id=906F00000008yWuIAI
2) https://github.com/abhinavguptas/Salesforce-Lookup-Rollup-Summaries
3) http://www.anthonyvictorio.com/salesforce/roll-up-summary-utility/
4) http://www.iterativelogic.com/developing-custom-apex-rollup-summary-field-logic/
5) http://blog.jeffdouglas.com/2011/08/23/salesforce-trigger-when-rollups-summaries-not-possible/
Let us know if this will help you
All Answers
Option 1:- Process builder
1) https://developer.salesforce.com/forums/?id=906F0000000BHvJIAW
2) https://developer.salesforce.com/forums/?id=906F0000000B2C0IAK
Option 2:- Trigger
1) https://developer.salesforce.com/forums/?id=906F00000008yWuIAI
2) https://github.com/abhinavguptas/Salesforce-Lookup-Rollup-Summaries
3) http://www.anthonyvictorio.com/salesforce/roll-up-summary-utility/
4) http://www.iterativelogic.com/developing-custom-apex-rollup-summary-field-logic/
5) http://blog.jeffdouglas.com/2011/08/23/salesforce-trigger-when-rollups-summaries-not-possible/
Let us know if this will help you
I have a field called amount__c on child and total_amount__c on parent.
total_amount__c takes the sum of all the values in amount__c in child.
To calculate Rollup Summary using the Trigger manually, you need to follow below:
Need to consider all DML operations like insert, update, delete and undelete of child records.
Insert of Child record:
--> Need to write an after insert trigger to update the Parent record with calculated sum value.
Update of Child record:
--> Make sure that the Parent information got changed.
--> Need to write an after update trigger and get both old and new Parent information and perform the re-calculation of sum.
Delete of Child record:
--> Need to write an after delete trigger to update the Parent record with re-calculated sum value.
Undelete of Child record:
--> Need to write an after undelete trigger to update the Parent record with re-calculated sum value.
Regards,
Mahesh