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.