0

We need an additional Set of Rollup fields which exceed Salesforce limit of 40 Rollup Fields on master detail records

The trigger should take consideration into all the below scenario's.

  • Should Update the old and Newly assigned parent record if the child record is re-assigned to a different Parent Record.
  • Should update the parent record if all the child records get deleted.
2

Don't.

Go install Declarative Lookup Rollup Summaries instead. It's free, open source, and thoroughly tested to take into account your scenarios and many others.

You can define your rollups declaratively, store them as Custom Metadata records, and have DLRS automatically generate and deploy the triggers required on both the parent and child objects.

There's no need to spend time reinventing this particular wheel, which has been invented so many times before. If, however, you insist on not using DLRS but creating something bespoke, you will find many references both on SFSE and elsewhere regarding trigger-mediated roll ups.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.