You need to sign in to do that
Don't have an account?

MISSING_ARGUMENT, Id not specified in an update call
on button click on opportunity... i am showing opportunityline items records on a page with line number using repeat.
I have used wrapper class for showing line number.
My Problem
opportunityline items fields are editable on page..so user can update them...i am having problem updating it...how to specify id for updating...
in Constructor
List<OpportunityLineItem> oli; oli=[Select Id,opportunityId From OpportunityLineItem where opportunityId=:id];
showsavedoppLineitems();
wrapper class
public list<linenumberclass> wrapperopllist;//List used in repeat on page public Class linenumberclass { public integer lineNumber{get;set;} public OpportunityLineItem oppLineNo{get;set;} public linenumberclass(OpportunityLineItem oppLineNo,Integer lineNumber) { this.oppLineNo=oppLineNo; this.lineNumber=lineNumber; } }
method called from constructor
public void showsavedoppLineitems() { List<OpportunityLineItem> lOpp=[select id,Business_Type__c,pricebookentry.pricebook2id,pricebookentryid from OpportunityLineItem where id in:opplineIttems]; for(OpportunityLineItem l:lOpp) { opline = new OpportunityLineItem (); opline.OpportunityId=id; opline.pricebookentry=pre.get(l.pricebookentryid); opline.pricebookentryid=l.pricebookentryid; opline.Territory1__c=l.Territory1__c; wrapperopllist.add(new linenumberclass(opline,m)); m++; } }
i am calling this method on button click...so i have the updated record value in oplist...
public list<OpportunityLineItem > opllist{get;set;}
public void add{ for(linenumberclass ln:wrapperopllist) { opline = new OpportunityLineItem (); opline.opportunityid=id; opline.PricebookEntry=ln.oppLineNo.pricebookentry; opline.PricebookEntryid=ln.oppLineNo.pricebookentryid; opline.Line__c=ln.linenumber; opllist.add(opline); } }
i dont know how to update oplist....
As i am showing the records in editable mode...if any user edits them and click on them records should be updated .
i dont know how to update existing records.i dont how to pass id.
please help me out this...thanks
So if you want to edit these records... change your method called to construct the list to...
You dont need to construct new line items...then change your add method and add an update statement on the list...
hey thanks andrew for replying...
in showsavedoppLineitems() methods
Map<id,Pricebookentry> pre=new Map<id,Pricebookentry>();
on page i am also showing "oppLineNo.PricebookEntry.Product2.name" which i dont get if i use your way...i get an exception.any way i can send that to wrapperopllist.
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: PricebookEntry.Product2
Since you are querying an object and using it in your page...You must query every field you want in your SOQL. So you need to add any fields referenced in your controller or page in the soql.
thanks andrew...but...as i an using a map to show "oppLineNo.PricebookEntry.Product2.name" on page...
as i cant query this field on opportunitylineitem....using your way as i am not able to show everything on page....is there any other to send id...pl bear with me if i am wrong somewhere..as i am learning....