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
akashakash 

Create a field called 'Latest Opportunity Amount' on Account. 2. Auto Populate the above field with the Newley created Opportunities’ Amount

Create a field called 'Latest Opportunity Amount' on Account.and then Auto Populate the above field  with the Newley created Opportunities’ Amount. How to do this.
PrabhaPrabha
If you are not factoring in Deletion, that will work.

And, you can do that with a small flow as well. Keep it simple.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Akash,

Can you try below trigger on Opportunity object.
 
trigger UpdateLatestOppAmount on Opportunity (after insert) {
    Set<Id> accountIds = new Set<Id>();
    for (Opportunity opp : Trigger.new) {
        accountIds.add(opp.AccountId);
    }

    Map<Id, Account> accounts = new Map<Id, Account>([
        SELECT Id, Latest_Opportunity_Amount__c
        FROM Account WHERE Id IN :accountIds
    ]);

    List<Account> accountsToUpdate = new List<Account>();
    for (Opportunity opp : Trigger.new) {
        Account account = accounts.get(opp.AccountId);
        if (account != null) {
            account.Latest_Opportunity_Amount__c = opp.Amount;
            accountsToUpdate.add(account);
        }
    }

    update accountsToUpdate;
}

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,