Can any one help me out on this Error: Invalid field selected for SObject OpportunityLineItem. This is a page created for multiple row to edit.Any suggestion plz. Here is the VF page :
<apex:form id="theForm">
<apex:pageBlock Title="ALL OPPORTUNITY PRODUCTS FOR ROW EIDTING">
<!--saving editing value -->
<apex:commandButton value="Save" action="{!tosave}" id="saveButton" />
<apex:outputPanel style="float:middle">
<!--display pageblock table.....-->
<apex:pageBlockTable value="{!OpportunityLineItem}" var="o" cellpadding="2" border="1" rowClasses="odd,even" styleClass="tableClass" id="opp_table">
<apex:column headerValue="All OpportunityProduct Name" >
<!--displaying checkbox inside column...-->
<apex:inputcheckbox value="{!o.selected}">
<!--invoking a controller function to know selected contacts.....-->
<apex:actionSupport event="onclick" action="{!getSelected}" rerender="Selected_PBS"/>
</apex:inputcheckbox>
<b><apex:outputField value="{!o.opp.product2.productcode}"/> </b>
</apex:column>
<apex:column headerValue="QUANTITY" >
<apex:outputfield value="{!o.opp.Quantity}" />
</apex:column>
<apex:column headerValue="SALES PRICE">
<apex:outputField value="{!o.opp.Unitprice}"/>
</apex:column>
<apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton"/>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlock>
Here is the code
public class MultipleOppRowEditing {
//All property....
public OpportunityLineItem oli{get;set;}
public Id Id{get;set;}
List<oliwrapper> oliList = new List<oliwrapper>();
List<OpportunityLineItem> selectedOpportunityLineItem = new List<OpportunityLineItem>();
//constructor....
public MultipleOppRowEditing(ApexPages.StandardController controller) {
OpportunityLineItem oli = new OpportunityLineItem();
}
//displaying contact pageBlock table....
public List<oliwrapper> getoli() {
for(OpportunityLineItem o: [select Id, product2.productcode,Unitprice,Quantity from OpportunityLineItem order by createdDate desc ])
oliList.add(new oliwrapper(o));
return oliList;
}
//all selected contacts...for edit...
public PageReference getSelected() {
selectedOpportunityLineItem.clear();
for(oliwrapper oppwrapper: oliList)
if(oppwrapper.selected == true)
selectedOpportunityLineItem.add(oppwrapper.opp);
return null;
}
public List<OpportunityLineItem> GetSelectedoli(){
if(selectedOpportunityLineItem.size()>0)
return selectedOpportunityLineItem;
else
// ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one opportunity.'));
return null;
}
//saving edited value...
public PageReference tosave() {
if(selectedOpportunityLineItem.size()>0){
update selectedOpportunityLineItem;
PageReference MultiOppLineItemEdit=new PageReference('/apex/MultiOppLineItemEdit');
MultiOppLineItemEdit.setRedirect(true);
return MultiOppLineItemEdit;
}
else{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one OppLineItem.'));
return null;
}
}
//wrapper class...
public class oliwrapper
{
public OpportunityLineItem opp{get; set;}
public Boolean selected {get; set;}
public oliwrapper(OpportunityLineItem o)
{
opp = o;
selected = false;
}
}
}
{!o.opp.product2.productcode}
oliWrapper
inner class you use a variable namedopp
to refer to anOpportunityLineItem
.opp
conveys notion of an opportunity, not a line item. The constructor in this inner class is equally afflicted