Skip to main content
1 risposta
  1. 25 dic 2022, 01:25
    Hi Tejas,

    try with below code.

    trigger contactUpdate on Contact(before insert,before update){

    set<id> accids = new set<id>();

    for(contact con:trigger.new){

    if(con.status__c=='Completed' && con.AccountId!=Null){

    accids.add(con.AccountId);

    }

    }

    map<id,account> mapaccidwithvaules = new map<id,account>();

    for(account acc : [select id,status__c from account where status__c='Completed' AND Id IN:accids]){

    mapaccidwithvaules.put(acc.id,acc);

    }

    for(contact con:trigger.new){

    if(mapaccidwithvaules.containskey(con.AccountId)){

    con.flag__c = true;

    }

    }

    }

    If this helps, Please mark it as best answer.

    Thanks!!​​​​​​​
0/9000