0

I am using Remote Object for Opportunity Product.I want to read Product2.Name but not able to define Product2 field in remoteobject type while it is standard field.My objective is to read Product2.Name from javascript.

   <apex:remoteObjects jsNamespace="RemoteObjectModel">
        <apex:remoteObjectModel name="OpportunityLineItem" fields="Id,OpportunityId,Product2">
         </apex:remoteObjectModel>
    </apex:remoteObjects>

I have tried Product,Product2,Product2.Name but all giving me error :

Save error: Invalid field 'OpportunityLineItem.Product2' specified. Ensure that you use the full API name for any custom fields.

  • Unfortunately, accessing parent objects, lookup, or child objects from a VisualForce Remote Object isn’t currently supported. I have to find another alternative. – unidha Nov 3 '16 at 8:09
1

Product2 is a readonly field, not an insertable field on OpportunityLineItems. You can use lookupfields, the previous comment is incorrect, I have done it.

You just have to use pricebookentryid, not Product2.

Opplineitems are very specific and you can get errors easily. You need OpporutunityId, Pricebookentryid, quantity, and Unit Price. Also the pbe has to be active, even if produt is active, if pbe is not active, you will get an error. This is important as most full sandboxes will not have all pb entries active.

I added the documention to this.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_opportunitylineitem.htm

The ID of the related Product2 record. This is a read-only field available in API version 30.0 and later. Use the PricebookEntryId field instead, specifying the ID of the PricebookEntry record.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.