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
jishan royjishan roy 

when opportunity description field update then all opportunity description field shows in account description field using trigger

Hii @all

can anybody help me to out of this question,

when opportunity description field update then all opportunity description field shows in account description field using trigger.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Jishan.

Do you need to update all the opportunity descriptions on account desciption using Trigger?

Thanks,
 
jishan royjishan roy
hi Sai praveen,

yes i need to update all opportunity description on account desciption using trigger.
Shri RajShri Raj
trigger UpdateAccountDescription on Opportunity (after update) {
  Set<Id> accountIds = new Set<Id>();
  for (Opportunity opp : Trigger.new) {
    Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
    if (opp.Description != oldOpp.Description) {
      accountIds.add(opp.AccountId);
    }
  }
  if (accountIds.size() > 0) {
    List<Account> accountsToUpdate = [SELECT Id, Description FROM Account WHERE Id IN :accountIds];
    for (Account acc : accountsToUpdate) {
      acc.Description = Trigger.newMap.get(acc.Id).Description;
    }
    update accountsToUpdate;
  }
}