function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dany__dany__ 

i am getting the following error ': Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id '


can some one help me out  (for the bello w trigger i am facing this problem)


trigger auto_con_led on Account (before insert)
{
//set<id>set1=new set<id>();
//list<account>ac=new list<account>();
list<contact>co=new list<contact>();
if(trigger.isinsert)
{
  for(account a:trigger.new)
  {if (a.name!=null)
   {contact c=new contact();
     c.lastname='jansi';
     c.accountid=a.id;
   co.add(c);
   }}
}
update co;
}
Best Answer chosen by dany__
Bhushan.AdhikariBhushan.Adhikari
You wont get an Id in before insert trigger. Try after insert trigger on account + update co will fail as you are creating a new contact, so it should be insert co.

All Answers

Bhushan.AdhikariBhushan.Adhikari
You wont get an Id in before insert trigger. Try after insert trigger on account + update co will fail as you are creating a new contact, so it should be insert co.
This was selected as the best answer
Prafull G.Prafull G.
Hi Pradeep,

You are performing an udpate statement on Contact List co. therefore you need to define Id/external id in this update call.
What actually you are trying to accomplish here? are you trying to create new contact for the newly inserted Account. If yes, then change the update statement at the end to insert.
i.e.
insert co;

Cheers!
dany__dany__
thnx Bhushan.Adhikari nd thnx prafull g .............................   u guys really helped me