function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GanjehGanjeh 

Can't access OpportunityLineItems info using the standard Opportunity controller?

Hello to all,

I've trying to create a simple VisualForce page for a client.  They want to modify the sales price on the opportunity product page with a slider.  I was trying to use the following code to simply pull some of the OpportunityLineItem details back from the opty on to my VF page:

<apex:page standardController="Opportunity">

    <body>
        <apex:panelGrid columns="1" styleClass="companyTable" width="100%">
            <apex:outputText value="{!$Organization.Name}" styleClass="companyName"/>
            <apex:outputText value="{!$Organization.Street}"/>
            <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}"/>
            <apex:outputText value="{!$Organization.Phone}"/>
        </apex:panelGrid>
        <apex:outputPanel layout="block" styleClass="line"/>
        <apex:panelGrid columns="1" styleClass="centered" width="100%">
            <apex:panelGrid columns="2" width="100%" cellpadding="0" cellspacing="0" columnClasses="left,right">
                <apex:outputText value="Opportunity Name {!Opportunity.name}" styleClass="customerName"/>
                <apex:outputText value="{!Opportunity.account.name}" styleClass="customerName"/>
            </apex:panelGrid>
        </apex:panelGrid>
        <apex:outputPanel layout="block" styleClass="lineSmall"/>
        <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
        <apex:panelGrid columns="2" columnClasses="left,right" width="100%">
            <apex:panelGroup >
                <apex:outputText value="{!line.name}" styleClass="productName"/>
                <apex:outputText value="{!line.id}" styleClass="productName"/>
            </apex:panelGroup>
        </apex:panelGrid>
        </apex:repeat>

    </body>
</apex:page>

 

but alas, I get this error message when I try to save the above page:

Error: Invalid field name for SObject OpportunityLineItem

 

I double checked the name of the relationship field and it's OpportunityLineItems in the WSDL...  Any direction would be much appreciated.

 

 

 

GanjehGanjeh

DOH!

 

I was looking for:

{!line.name}

 name is a field which does not exist on the OpportunityLineItems object :smileyvery-happy:

 

Have a good day all.