답변 1개
Hi Tejas, try with below code.
If this helps, Please mark it as best answer.Thanks!!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;
}
}
}