I'm working on a small trigger that will update the Contract object with the sum of the total price on a custom Subscription object is not a child record of the contract object. Contract:Subscription is one:many.
I've created a Contract custom currency field, MRR, (Monthly Recurring Revenue). My objective is to loop through all related Subscription records, obtain the total price for each subscription, aggregate them together and insert this value onto the Contract.
I've chosen to create the trigger on the Subscription object, though I suspect it may be simpler to do so on the Contract object. Here is what I have so far:
I'm trying to match the Subscription.Contract.Id to the Contract Id. Once I have a list of Subscriptions, I will update the Contract record.
What is the simplest approach to accomplish this?