+ Start a Discussion
Linda 98Linda 98 

Missing argument,Id not specified in an update call.

I have a trigger to create a child, sub child records when status is changed.
like. Opportunity with line items and when  status changed then create customobject__c and its line items.
Everything works fine till here.
but when a field on opportunity line items called as 'numberoflines' is updated, I am trying to update 'totallines' field on customobject line items object
I created a trigger on Opplineitems,which when changed,have to update totallines field onn customobjectlineitems.
trigger totallineupdate on Opplineitem (before update) {

    Map<id,customobjectlineitem__c> newMap =new Map<id,customobjectlineitem__c>();
    
    for(Opplineitem Oli :trigger.new)
    {
        
        Opplineitem oldLi = Trigger.oldMap.get(Oli.id);
        
        if(Oli.Numberoflines != OldFL.Numberoflines){
                
            customobjectlineitem__c Coli =new customobjectlineitem__c(Opportunity__c=oli.Opportunity__c,Totallines=oLI.numberoflines);
            newMap.put(OLI.Opportunity__c,coli);         
      }
   }
   update newMap.values();   //id not specifed error here
   
}


What am I doing wrong?

I used opportunity, opportunity line items as examples as it explains relations.Thank you


 
Raj VakatiRaj Vakati
Try ilke this .. 
 
trigger totallineupdate on Opplineitem (before update) {

    Map<id,customobjectlineitem__c> newMap =new Map<id,customobjectlineitem__c>();
   Map<Id,Opplineitem> odl = new Map<Id,Opplineitem>();
    for(Opplineitem Oli :trigger.new)
    {
        
        Opplineitem oldLi = Trigger.oldMap.get(Oli.id);
        
        if(Oli.Numberoflines != OldFL.Numberoflines){
			odl.put(Oli.Id ,Oli);
            //customobjectlineitem__c Coli =new customobjectlineitem__c(Opportunity__c=oli.Opportunity__c,Totallines=oLI.numberoflines);
           // newMap.put(OLI.Opportunity__c,coli);         
      }
   }
   
   List<customobjectlineitem__c> olds =[Select Id ,Opportunity__c,Totallines,from customobjectlineitem__c where Id In :odl.keySet()];
   
   for(customobjectlineitem__c o :olds){
	   o.Totallines = odl.get(o.Opportunity__c).numberoflines;
   }
   
   update olds ;
   
 //  update newMap.values();   //id not specifed error here
   
}