function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CRMsimpleCRMsimple 

Trigger to update account after insert or update of an opportunity

Anyone have some sample trigger code that might help me with the following?:
 
On Opportunities, we have a second account lookup field which is a lookup to a partner account. We'd like to be able to mimic the summary roll-up type field to sum the total amount of opportunities that are closed won, lost, open etc. but because the account is secondary, a non master-detail relationship, this isn't possible without a trigger.
 
So I'm thinking that when this account is pulled into the opportunity via the lookup field, the trigger could pull in the opportunity amount value and add it to this "summary roll-up" type field on the partner account and keep increasing the amount each time a new opportunity is linked to this account or is updated, if it already exists. 
 
If it could have the ability to evaluate the stage and record type that would help too.
 
 
Can anyone provide any "starter" code samples that might help me get started? I understand what needs to happen, but my knowledge of writing code is very limited.
 
Any help would be greatly appreciated.
 
Thanks