Advertisement
f1lam3ntx0

contact creation via account

Aug 21st, 2022 (edited)
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. Trigger accCreation on Contact (After Insert){
  2.   switch on Trigger.operationType{
  3.     when BEFORE_INSERT{
  4.       accCreationHelper.createContact(Trigger.new);
  5.     }
  6.   }
  7. }
  8.  
  9. Public with sharing accCreationHelper{
  10.   public static void createContact(List<Account> accList){
  11.   if(accList != null){
  12.   List<Contact> conUpdate = new List<contact>();
  13.   for(Account a : accList){
  14.   List<contact> conList = new List<contact>();
  15.     for (Integer i = 0 ; i == accList.size() ; i++){
  16.       contact con = new contact();
  17.       con.Id = a.Id;
  18.       con.name = a.name+'i';
  19.       conUpdate.add(con);
  20.      
  21.     }
  22.   }
  23.   Insert conUpdate;
  24.   }
  25.   }
  26. }
Tags: Triggers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement