1

Error:Apex trigger leadupdatecontact caused an unexpected exception, contact your administrator: leadupdatecontact: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.leadupdatecontact: line 10, column 1

trigger leadupdatecontact on Lead(after update){
 list<contact> con=new list<contact>();
// list<lead> lea=new list<lead>();
for(Lead le :trigger.new){     
  contact co=new contact();       
    if((le.description!= Null)&&(co.description!=le.description))     
       co.description=le.description; 
       co.id=le.convertedcontactid; 
       con.add(co); 
       update con;
    }
 }
2
  • What are you trying to achieve in the statement co.id=le.convertedcontactid ? are you trying to manually assign contact id.
    – codebandit
    Oct 29, 2013 at 9:18
  • When a Lead is converted, the "Description" of the lead is going to the "Description" of the newly created contact. If I convert a Lead into an existing contact, then the "Description" of the lead goes nowhere. to add the Description of this lead to existing Description of the existing contact?
    – Teja
    Oct 29, 2013 at 9:27

2 Answers 2

2

Not sure what you are trying. Seems like you want to copy description from lead to the related contact.

Well You can modify the code lil bit so that only converted leads goes inside the loop.

trigger leadupdatecontact on Lead(after update){
 list<contact> con=new list<contact>();
// list<lead> lea=new list<lead>();
for(Lead le :trigger.new){     

    if(le.convertedcontactid != NULL && le.description!= Null && co.description!=le.description ){
       contact co=new contact();   
       co.description=le.description; 
       co.id=le.convertedcontactid; 
       con.add(co); 

    }
  }
   update con;
 }

Update : In the "Custom Fields" section of Leads screen is a button for Lead Field Mapping. Lead Field Mapping can map only custom Lead fields, and they can only be mapped to custom Account, Contact, Opportunity fields.

In your case the field to be mapped is standard field.So I think you need a trigger.

9
  • When a Lead is converted, the "Description" of the lead is going to the "Description" of the newly created contact. If I convert a Lead into an existing contact, then the "Description" of the lead goes nowhere. to add the Description of this lead to existing Description of the existing contact?
    – Teja
    Oct 29, 2013 at 9:30
  • @Avidev9 Please remove update out of for :).Not the best in sfdc Oct 29, 2013 at 9:33
  • still i am facing the same error.could you have other option
    – Teja
    Oct 29, 2013 at 9:36
  • @user4045 I dont think the error will happen there is a check before the loop and it wont even go inside it until and unless it finds a record with an Id
    – Avidev9
    Oct 29, 2013 at 9:39
  • 1
    Mark the answer as answered and upvote if that helped !Thats how we grow in community and marking an answer as true certainly helps other people to find this easily . Oct 29, 2013 at 10:23
2

There is a small error and your code should be this:

trigger leadupdatecontact on Lead(after update){
 list<contact> con=new list<contact>();
  contact co=new contact();       
// list<lead> lea=new list<lead>();
for(Lead le :trigger.new){     

   if((le.description!= Null)&&(leConvertedContact.description!=le.description)) {
       co=new contact();            
       co.description=le.description; 
       co.id=le.convertedcontactid; 
       con.add(co); 
    }
   }
update con;
 }  
5
  • i want only update i will tell what i need
    – Teja
    Oct 29, 2013 at 9:33
  • When a Lead is converted, the "Description" of the lead is going to the "Description" of the newly created contact. If I convert a Lead into an existing contact, then the "Description" of the lead goes nowhere. to add the Description of this lead to existing Description of the existing contact?
    – Teja
    Oct 29, 2013 at 9:33
  • Any ideas you can help me
    – Teja
    Oct 29, 2013 at 9:42
  • Did an update re your comments Oct 29, 2013 at 9:42
  • i am facing error while updating the description in lead
    – Teja
    Oct 29, 2013 at 9:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .