You need to sign in to do that
Don't have an account?
meyerd
Set PriceBookEntry.Name of Opportunity Line Item for display in VF page.
Set PriceBookEntry.Name of Opportunity Line Item for display in VF page.
I am using a datatable to show a list of Opportunities. I initially query for and display directly from sfdc.
I have another method that adds to lit and re-renders that section.
I want to set PriceBookEntry.Name for display in the VF page
Something like
I can execute/save the code that sets the PriceBookEntry.Name through eclipse using v10 of the Api.
However through the UI [saving apex code or saving from the vf controller editor] I get the message.
Error: Compile Error: Field is not writeable: PricebookEntry.Name at line 54 column 17.
I am using a datatable to show a list of Opportunities. I initially query for and display directly from sfdc.
Code:
public List<OpportunityLineItem> getLineItemsTechnology() { if(lit == null){ lit = [select PriceBookEntry.Name, Mix__c, Quantity, UnitPrice, PriceBookEntry.ProductCode from OpportunityLineItem where OpportunityId = :oid and PriceBookEntry.ProductCode = 'Technology']; } return lit; }
I have another method that adds to lit and re-renders that section.
I want to set PriceBookEntry.Name for display in the VF page
Something like
Code:
OpportunityLineItem tmpOLI = [select Mix__c,PriceBookEntry.Name from OpportunityLineItem limit 1]; OpportunityLineItem newOLI = tmpOLI.clone(false); newOLI.PriceBookEntry.Name = 'Set Name For Display in VF Page Datatable';
However through the UI [saving apex code or saving from the vf controller editor] I get the message.
Error: Compile Error: Field is not writeable: PricebookEntry.Name at line 54 column 17.
PricebookEntry is master-detailed to Product2 where it gets it's name, i.e. PricebookEntry.Name is a derived field from Product2.Name so this error is correct and not to mention it's better to get this at compile time than runtime.
For this specific issue, if you want to display some descriptive text along side each line item in your visualforce page then you could create a wrapper class that has a String and PricebookEntry member (and associated accessors) and then just display the collection of these wrapper objects. Alternatively if you want to pull a custom field from the product2 or opportunityLineItem object you can do that as well.
I am going to move this to the VF board because the solution seems to be specific to that area.
Error: Compile Error: Field is not writeable: ProductCode at line 67 column 115
The line being
defaultServicePBE = new PricebookEntry(isActive=true,UnitPrice=5,product2Id = newProduct.Id,ProductCode='Service',Pricebook2Id=defaultPricebookId,CurrencyIsoCode=currentUser.defaultCurrencyIsoCode);
This code is part of a test method.
PricebookEntry.ProductCode is also not editable as it is similarly derived from the related product2 object.
I will open some inquiries internally but rest assured the current behavior is correct.