You need to sign in to do that
Don't have an account?
superlou
Product2 invalid while Iterating over OpportunityLineItems
With the standard controller for Opportunity, I am trying to generate a list of line items (products) with custom formatting. I am using the following:
<apex:page renderAs="pdf" standardController="Opportunity">
<h2>Items</h2>
<apex:repeat value="{!Opportunity.OpportunityLineItems}" var="OLI">
{!OLI.Product2.name}
</apex:repeat>
</apex:page>
However, Product2 seems to pretty clearly a standard field in the line item SObject. Other fields like CreatedBy and Discount work fine. Is there a gotcha for dealing with references?
Thanks,
Louis
Try this:
{!OLI.PricebookEntry.Product2.name}
instead of {!OLI.Product2.name}
Make sure to include the PricebookEntry.Product2.name in your SOQL statement.
~NK
Akze and sfdcfox, thanks for the clues! That did the trick.
I'm not sure the most tactful way to put this, but is it common for gotchas like this to be in the Salesforce UI? Under App Setup > Customize > Opportunities > Opportunity Products > Fields, there's no indication of PriceBookEntry and Product2 is clearly listed. I'll treat the SOAP API guide (http://www.salesforce.com/us/developer/docs/api/index.htm) as the gold standard, but what causes this sort of discrepency (if it even is)?