In apex-code i have wrote 2 triggers. I have 2 objects A and B. I need to create records of B object when A object is created. For eg: When 1 record of Object A is created then then create 4 records of object B. I have wrote 2 trigger 1 is for default some fields in B object when A object is created (this is before insert, before update) trigger and 2 trigger is to create record of object B when record of A is created(this is after insert, after update) trigger.
But when i create i record of Object A then 4 record id created. But when used Apex Data Loader to create records of object A at that time 2 records are created for A but for B object only 4 records are create. This is created for the second record of the A object.
i changed the code to
for(Object e : Trigger.new){
for(){ create 4 records for B object }}
I am getting this error when i did it
Insert failed. First exception on row 0 with id abcdef12345; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
Can any body help me to solve the problem. Thanks Anu