You need to sign in to do that
Don't have an account?
TRIGGER when account record is created corresponding contact should be created....what is id here?
trigger TriggerAccountContacts on Account (after insert) { list<contact> cons=new list<contact>(); for(account a:trigger.new){ contact c=new contact(); c.lastname=a.name; c.Phone=a.phone; c.Description=a.description; c.AccountId=a.id; //what is accountid here is it record id of account object cons.add(c); } insert cons; }
Account's record id is getting stored into contact's Accountid that means in accounts lookup in contact object in every iteration of that for loop.
Every child will have an lookup field of its parent object which indeed can store its parent id in it.
Regards,
Ankit
All Answers
c.AccountId=a.id;// assigning account id to contact objects account id
Account's record id is getting stored into contact's Accountid that means in accounts lookup in contact object in every iteration of that for loop.
Every child will have an lookup field of its parent object which indeed can store its parent id in it.
Regards,
Ankit