8

When I ran below query in workbench/developer console

SELECT product2 FROM OrderItem

am getting below error

No such column 'Product2' on entity 'OrderItem'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

But I see Product2 field in Order Product I am not sure why I am getting this error

enter image description here

3 Answers 3

11

There is no direct binding to the Product table from Order Lines, the link is actually through PricebookEntries. So the SOQL to get the ProductId would be:

select Pricebookentry.Product2Id from OrderItem

1

credit to @sfdcfox for noting that the Product2 relationship on OrderItem is part of the latest API versions and the SOQL query above should work with API version 57.0

0

Try doing:

SELECT product2id from OrderItem

We do not have orders enabled but this works for OpportunitLineItems which is its close cousin.

1
  • Same error message : No such column 'product2id' on entity 'OrderItem'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
    – sfdc
    Commented Mar 24, 2015 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .