Skip to main content
답변 4개
  1. 2021년 2월 23일 오후 1:36
    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...
0/9000