• Sia Thripio 6055
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
this code is not reflecting my UI . why?
trigger citytrigger on Account (after update) {
    
   List< Opportunity> OppListToUpdate=new  List< Opportunity > ();
    map<id,account> Accmap=new map<id,account>();
    for(Account a:trigger.new){
        if(a.accCity__c !=trigger.oldmap.get(a.id).accCity__c)
            Accmap.put(a.id,a);
    }
    
    if(!Accmap.isEmpty()){
        Set<id> AccIDs=Accmap.keyset();
         List< Opportunity>  Opplist=[Select AccountId,city__c,Account.accCity__c  from Opportunity where AccountId  in :AccIDs];
        
        if(Opplist.size()>0){
            for(Opportunity o: Opplist ){
                o.city__c=Accmap.get(o.accountId).accCity__c;
                OppListToUpdate.add(o);
            }
        }
    }
    
    if(OppListToUpdate.size()>0){
        update OppListToUpdate;
    }
}