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
kali charankali charan 

Populating the average amount field on account object based on the contact amount field

Hi Everyone,


  I am a newbie to salesforce and and i have a requirement that I have an **Average amount** number field in account and **Amount** number field in contact and stage picklist in contact and stage picklist values are hot,cold ,warm.I have a scenario like if the stage value is hot the contact amount field should be directly populated on Average amount of account field and if the stages of contact is rather than hot the average of all the amounts of multiple contacts should be populated on the account average amount field.It should work if new contacts are inserted and even for update.


       My requirement is i have to write class in the logic and that should be called from the class.


Thanks.
VineetKumarVineetKumar
Write a trigger, that can call invoke the method in your class to meet this requirement.
Let me know if you get stuck in trigger.
kali charankali charan
Hi Vineet thanq for your reply can u please send me the trigger logic
VineetKumarVineetKumar
you can refer the below link to learn to write a trigger :
https://developer.salesforce.com/trailhead/en/apex_triggers/apex_triggers_intro

There are few examples that you can refer to start writing a trigger.