• Narasimha Reddy 164
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
trigger updatecontact on Account (after insert, after update) {
list<Contact> conlist=new list<Contact>([select Id,Name,AccountId,Industry__c from Contact where AccountId IN:Trigger.new ]);
    map<Id,Account>mapAccountIdAccount=new map<Id,Account>([select Id,Industry,AccountSubType1__c,AccountType1__c,businessunit__c,ProductInterest__c,
                                                            TranslocRelationship__c from Account where Id IN:Trigger.new]);
  list<Contact>contactstobeupdate=new list<Contact>();
    if(Trigger.isInsert || Trigger.isUpdate && Trigger.isAfter) {
        
        for(contact obj:conlist){
            
            Account objAccount=mapAccountIdAccount.get(obj.AccountId);
            obj.TranslocRelationship__c =objAccount.TranslocRelationship__c;
            obj.ProductInterest__c=objAccount.ProductInterest__c;
            //obj.Industry__c=objAccount.Industry;
            obj.AccountType__c=objAccount.AccountType1__c;
            obj.AccountSubType__c=objAccount.AccountSubType1__c;
            contactstobeupdate.add(obj);
        }
        update contactstobeupdate;
    }
  }