You need to sign in to do that
Don't have an account?
akkk
count the sum of child records on the child object not on the parent object with trigger ?
Hi all
is it possbile ?
count the sum of the child records on the child object not on the Parent object with trigger .
Thanks
akkk
is it possbile ?
count the sum of the child records on the child object not on the Parent object with trigger .
Thanks
akkk
>> https://developer.salesforce.com/forums/?id=906F0000000D9dvIAC
In the above examples depending on the relationship between the objects there are different ways to achieve the above use case, can you try checking them.
For quick reference, below is the best answer selected in above link:
Generally these kinds of requirements we can achieve in 2 ways:
--> If the relationship between the objects is Master-Details then we can use OTB functionality called the 'Roll-Up Summary' field.
--> If the relationship between the objects is Lookup then have to create multiple triggers to fulfill this functionality.
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.
Also, look into the below options as well from other posts:
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 me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
this is not currect answer of my question becasue want to sum of count of the child records update on child record not on the parent records
Thanks
YES, correct this is Scenario.
Thanks
Akk
Please note this is a sample snippet and you can modify the above snippet as per your need.
Thanks.