+ Start a Discussion
Derek Bennett 5Derek Bennett 5 

Write a class with a method that updates all of an accounts contacts, setting contact field called “active to false”

Anyone know the code for this?

Write a class with a method that updates all of an accounts contacts, setting contact field called “active to false”
NatsuNatsu
public class AccountHelper{
   
  public static void updateContact(Account acc){
  list<Contact> conList=[select id from contact where accountid=:acc.id];
  if(conList.size()>0){
  for(Contact c:conList){
  c.active_to_false__c=false;
  }
  try{
    update conList;
   }
  catch(Exception DmlException)
  {
    //your error handling code here
  }
  }
 
  }

}

 
Raj VakatiRaj Vakati
public class AccountHelper{
   
  public static void updateContact(List<Id> accList){
  list<Contact> conList=[select id from contact where accountid IN :accList];
  if(conList.size()>0){
  for(Contact c:conList){
     c.active_to_false__c=false;
  }
  try{
    update conList;
   }
  catch(Exception DmlException)
  {
   }
  }
 
  }

}