• Martin Abanes
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Here is my Apex trigger:

trigger AccountAssignment on Contact (after insert, after update) {
    
        List<Contact> conToInsert = [select id, accountid from contact  where id in: trigger.newmap.keyset()];


        Account defaultAccount = [SELECT ID FROM account Where ID  = '001i0000010asN9' limit 1]; 
       
        //record id of Dummy Account is 001i0000010asN9
     
          for (Contact c : conToInsert) {            
                      
                if( c.accountid == NULL)
              {        
             
                c.accountid = defaultAccount.id;    
                 
               conToInsert.add(c);           
            
               }           
        }    
        }
Here is my Apex trigger:

trigger AccountAssignment on Contact (after insert, after update) {
    
        List<Contact> conToInsert = [select id, accountid from contact  where id in: trigger.newmap.keyset()];


        Account defaultAccount = [SELECT ID FROM account Where ID  = '001i0000010asN9' limit 1]; 
       
        //record id of Dummy Account is 001i0000010asN9
     
          for (Contact c : conToInsert) {            
                      
                if( c.accountid == NULL)
              {        
             
                c.accountid = defaultAccount.id;    
                 
               conToInsert.add(c);           
            
               }           
        }    
        }