+ 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.

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

Traci Whetzel 8Traci Whetzel 8

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"
    subject="Productline Items for Opportunity: {!relatedTo.name}"
    replyTo="support@acme.com"  >
<messaging:htmlEmailBody >        
         <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}
                  <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}  
       <table border="0" >
                 <tr > 
                     <th>Action</th><th>Product Name</th><th>Quantity</th><th>Unit Price</th><th>Total Price</th>
    <apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
           <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>
       <p />
<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)} ]


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! 
Borann IngBorann Ing
Hello everyone,

I have the same issue. I follow all the steps recommended by you but it does not work. Does anyone find a solution? Please kindly share and I really appreciate it. Thanks in advance!

User-added image

Visualforce code:

<apex:page standardController="Filleul__c">


<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyASUR_G8o_HDm77OEnVbaw2logXemdjt18&callback=initMap" ></script>
<script type="text/javascript"> 
$(document).ready(function() {
  var myOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
  var map;
  var latlng = new google.maps.LatLng(parseFloat({!Filleul__c.Latitude__c}),parseFloat({!Filleul__c.Longitude__c}));
  var geocoder = new google.maps.Geocoder();
  geocoder.geocode( { location: latlng}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);
        //center map
        //var marker = new GMarker(center, {draggable: true});
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Filleul__c.Name}", 
            draggable: true
        //add listeners
        GEvent.addListener(marker, "dragstart", function() {
        GEvent.addListener(marker, "dragend", function() {
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Les latitude et longitude pour le filleul {!Filleul__c.Name} ne sont pas valides.");
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";

#map {
  font-family: Arial;
  line-height:normal !important;

<div id="map"></div>