You need to sign in to do that
Don't have an account?
Yokesh Narayanan K
Trigger on opportunity for max amount
Create a field high Opportunity amount on Account object and write a trigger on Opportunity to populate the highest amount among all opportunity for a single Account on Account Object
Refer the below link have solution.
https://developer.salesforce.com/forums/?id=906F00000008yLMIAY
https://salesforce.stackexchange.com/questions/201083/how-to-find-max-of-amount-of-opportunity-related-to-account
If still facing issue, let me know will help you with code.
Thanks!!
I saw these articles above mentioned, but still I didn't get enough clarification to write a code for bulkification.
This is my code,
List<Account> lstAcc= new List<Account>();
for(Opportunity opp:trigger.new)
{
set<Id> accIds = new set<Id>();
Account acc = [SELECT Id FROM Account WHERE Id =:opp.AccountId];
List<AggregateResult> highAmount = [SELECT MAX(Amount) High_Amount
FROM Opportunity
WHERE AccountId =:acc.Id];
}
Kinda stuck here , since for bulkfication we cant use soql in for loop .
Instead of trigger, You can create a rollup summary field on Account object.
Field Name : high Opportunity amount
Data type: Rollup summary
Refer the below screenshot.
If you still need to do this using trigger then let me know.
If this helps, Please mark it as best answer.
Thanks!!
If this helps, Please mark it as best answer.
Thanks!!
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh