SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class AVX_EliminarContacto {
  2.     public static void eliminar_contacto(List<Contact> listaContactos){
  3.                
  4.         List<ID> listIdContacto = new List<Id>();
  5.         List<Case> lstCasos;
  6.        
  7.         for(Contact contacto:listaContactos){
  8.             if (contacto.IsPersonAccount==false){
  9.                 listIdContacto.add(contacto.id);
  10.             }
  11.         }
  12.         if (listIdContacto.size()>0){
  13.             lstCasos = [SELECT id, ContactId FROM CASE WHERE ContactId IN: listIDContacto];
  14.        
  15.             if (lstCasos.size()>0){
  16.                
  17.                 for(Case caso:lstCasos){
  18.                     caso.ContactId=null;
  19.                 }
  20.                 update lstCasos;    
  21.             }
  22.                 delete listaContactos;
  23.         }
  24.     }
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top