4 answers
Hii srikanth yeturu Try the Following Code Just Copy Paste It.
trigger ownerUpdate on Contact (before Update) {
Set<Id> relatedAccountId = new Set<Id>();
List<Account> updatedList = new List<Account>();
string ownerid;
for(Contact con: trigger.new){
if(con.AccountId != Null){
relatedAccountId.add(con.AccountId);
ownerid = con.OwnerId;
}
}
for(Account acc: [Select Id, Name ,OwnerId from Account where id in : relatedAccountId]){
acc.OwnerId = ownerid;
updatedList.add(acc);
}
update updatedList;
}
Please Mark It As Best Answer If It Helps.
Thank you...