• Santosh Borfalkar 7
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
/*Write a trigger that creates two identical Contacts whenever an Account is created. Make sure both Contacts are associated with the Account. Use any values for the fields on the Contacts - just make sure to use variables when populating the fields of each Contact to make sure they are identical.*/

I am not able to associate contacts with Account , this is my code

trigger IdenticalContact on Account (before insert) {          for (Account a : trigger.new)     {         List<contact> cont = new List<contact> ();         for (integer i=0 ; i<2; i++)         {             contact newContact            = new contact();             newContact.AccountId          = a.id;             newContact.LastName           = 'kritpa';             newContact.FirstName          = 'ptName';             cont.add(newContact);         }      insert cont;     }



 
/*Write a trigger that creates two identical Contacts whenever an Account is created. Make sure both Contacts are associated with the Account. Use any values for the fields on the Contacts - just make sure to use variables when populating the fields of each Contact to make sure they are identical.*/

I am not able to associate contacts with Account , this is my code

trigger IdenticalContact on Account (before insert) {          for (Account a : trigger.new)     {         List<contact> cont = new List<contact> ();         for (integer i=0 ; i<2; i++)         {             contact newContact            = new contact();             newContact.AccountId          = a.id;             newContact.LastName           = 'kritpa';             newContact.FirstName          = 'ptName';             cont.add(newContact);         }      insert cont;     }