You need to sign in to do that
Don't have an account?
Erik Rodgers
Help with SOQL
I'm attempting what I believe to be a fairly simple and straight-forward SOQL query to get fields from the Salesforce Order Product (OrderItem) standard object. I am also attempting to reference a couple fields on the Product (Product2) object that is related to Order Product via lookup field Product. Here is my query:
SELECT Id,
OrderId,
OrderItemNumber,
Product2.Name,
Quantity,
UnitPrice
FROM OrderItem
All profiles has field level visibility off all fields, but the query errors with "INVALID FIELD - No such relation Product2 on entity OrderItem." What am I doing wrong. This field most certainly exists as a lookup to the Product object. The query runs fine if I take out "Product2.Name"
SELECT Id,
OrderId,
OrderItemNumber,
Product2.Name,
Quantity,
UnitPrice
FROM OrderItem
All profiles has field level visibility off all fields, but the query errors with "INVALID FIELD - No such relation Product2 on entity OrderItem." What am I doing wrong. This field most certainly exists as a lookup to the Product object. The query runs fine if I take out "Product2.Name"
There is no direct association between Order and Product2. it is always accessible throught Pricebookentry so following query will work for you.
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.