+ Start a Discussion
Traci Whetzel 8Traci Whetzel 8 

Error: Invalid field Customer_Standard_Price_Sales__c for SObject OpportunityLineItem

I would like to know how I reference a custom field as part of this visual force page for Opportunity Line Items. The template is from this app, on the Appexchange form Salesforce labs: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N300000016cYlEAI&modal=where_to_install_package

The error states that it is an invalid field, but it's a custom field on the product. 

Any help would be appreciated!
VF Error
Best Answer chosen by Traci Whetzel 8
Dushyant SonwarDushyant Sonwar
Tracy , 

I think that field name is different that you are using Customer_Standard_Price_Sales__c , in the attached screenshot it is showing Customer_Standard_Price__c as field name

Hope this helps :)
 

All Answers

Raj VakatiRaj Vakati
i think you need to use RelatedTO.YOURFIELD NAME 
Dushyant SonwarDushyant Sonwar
I am not sure whether this will work but I think it is worth trying.
Please try with below line.
opp.product2.Customer_standard_price_sales__c

Hope this helps.
 
Traci Whetzel 8Traci Whetzel 8
Dushyant - same error message.

 
Traci Whetzel 8Traci Whetzel 8
<td>{!relatedTo.Customer_Standard_Price_Sales__c}</td>

Raj - this did not work either.
Dushyant SonwarDushyant Sonwar
Tracy ,

Did you created this field on opportunityLineItem ?
Could you please double check?

It may happen that you may have accidentally created it on opportunity you might be looking the field in opportunitylineitem.

it is working fine in my scenario.
User-added image

If that is not the case , please put the screenshot of custom fields and relationship , that will help us to dig into this problem.
Traci Whetzel 8Traci Whetzel 8
It's on the opportunity product, not on the opportunity. Could you copy your code so I can see it, please?
Dushyant SonwarDushyant Sonwar
<messaging:emailTemplate recipientType="Contact"
    relatedToType="Opportunity"
    subject="Productline Items for Opportunity: {!relatedTo.name}"
    replyTo="support@acme.com"  >
    
<messaging:htmlEmailBody >        
    <html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
               TD  {font-size: 11px; font-face: verdana } 
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
                  <font face="arial" size="2">
        <p>Dear {!recipient.name},</p>
        <p>Below is a list of products related to the Opportunity:<b> {!relatedTo.name}</b>.</p>
        <br/>Account: <i> {!relatedTo.Account.name}  </i>  
        <br/>Opportunity Owner: {!relatedTo.owner.name}
        <br/>Opportunity Amount: {!ROUND(relatedTo.Amount,0)} 
        <br/>Opportunity Close Date: {!relatedTo.CloseDate}  
   
        <p/>                  
       <table border="0" >
                 <tr > 
                     <th>Action</th><th>Product Name</th><th>Quantity</th><th>Unit Price</th><th>Total Price</th>
                  </tr>
    <apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
       <tr>
           <td><a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}">View</a> |  
           <a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}/e">Edit</a></td>
           <td>{!opp.PriceBookEntry.name}</td>
           <td>{!ROUND(opp.Quantity,0)}</td>
           <td>{!ROUND(opp.UnitPrice,0)}</td>
           <td>{!ROUND(opp.TotalPrice,0)}</td>
           <td>{!opp.Customer_Standard_Price_Sales__c}</td>
       </tr>
    </apex:repeat>                 
       </table>
       <p />
 </font>
       
        </body>
    </html>
</messaging:htmlEmailBody> 
    
<messaging:plainTextEmailBody >
Dear {!recipient.name},
 
Below is a list of products related to the Opportunity: {!relatedTo.name}

Account: {!relatedTo.Account.name}
Opportunity Owner: {!relatedTo.owner.name}
Opportunity Amount: {!ROUND(relatedTo.Amount,0)} 
Opportunity Close Date: {!relatedTo.CloseDate}  


[ Product Name ] - [ Quantity ] - [ Units ] - [ Total Price ]
-------------------------------------------------------------------------

<apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
[ {!opp.PriceBookEntry.name} ] - [ {!ROUND(opp.Quantity,0)} ] - [ {!ROUND(opp.UnitPrice,0)} ] - [ {!ROUND(opp.TotalPrice,0)} ]
</apex:repeat>

</messaging:plainTextEmailBody>       
        
</messaging:emailTemplate>

 
Traci Whetzel 8Traci Whetzel 8
User-added image
Dushyant SonwarDushyant Sonwar
I have attached the code snippet for the vf email template .Could you post the image of Opportunity Product and Relationship section , please?
Dushyant SonwarDushyant Sonwar
Tracy , 

I think that field name is different that you are using Customer_Standard_Price_Sales__c , in the attached screenshot it is showing Customer_Standard_Price__c as field name

Hope this helps :)
 
This was selected as the best answer
Traci Whetzel 8Traci Whetzel 8
THANK YOU! Sometimes you look at something for so long the obvious is missed. I truly appreciate the help!