You need to sign in to do that
Don't have an account?
Michelle Grant
Best practice question: Parent update triggering update on children
This is not a how to question, but a best practice/opinion question. I have a request to update a calculation on specific child records when a field on a parent record is updated. I am hesitant to do this since then the children records will go through the entire save procedure (including a good amount of Apex code), so it would add a bit more processing to the Apex transaction. My question is, when would you go ahead with this request vs pushing back and trying to find another solution (i.e. batch update of the child records every hour/night, new business process-- after updating the parent, go and check this checkbox on the children, . . . )? In general there shouldn't be more than 5 child records per parent that need to be updated.
About the rollup calculations you are right. The Trigger will fire on parent record if there is a modification on the field of child record that feeds to the parent as roll up only.
I hope above answers your question.
Thanks
Shashikant
All Answers
Hi Michelle,
I would suggest to do it in After Insert Trigger of Parent Record as there are only 5 childs per parent so should not be an issue as Triggers work in chunk of 200 so even at bulk case scenario you will only have 1000 child records to update. This is the general and best practice for this scenario.
One thing I would like you to see is possiblity of Formula field on child object so you dont even require a Trigger.
Thanks
Shashikant
I thought about a formula field, but I don't think that would be best for this use case. Thanks for the idea though.
About the rollup calculations you are right. The Trigger will fire on parent record if there is a modification on the field of child record that feeds to the parent as roll up only.
I hope above answers your question.
Thanks
Shashikant