You need to sign in to do that
Don't have an account?
Reema
What is wrong with the query?
List<Product2> listOfProducts = [SELECT Id, Name, Description, IsActive, Parent_Product__c, Account__c ,
(SELECT Id, Product2Id, Quantity FROM OrderItem) FROM Product2
WHERE Account__c = 'XYZ'];
ERROR at Row:2:Column:74
Didn't understand relationship 'OrderItem' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
(SELECT Id, Product2Id, Quantity FROM OrderItem) FROM Product2
WHERE Account__c = 'XYZ'];
ERROR at Row:2:Column:74
Didn't understand relationship 'OrderItem' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
If i am not rong the OrderItem and The Product2 both are custom fields !?
if yes you need to use that like OrderItems__c ,Product2__c try like this it will work ( id you are uding the child to parent relationship you should use the label name in this case it might be OrderItems__c for sub class only) other else query is all correct check the fields too
They are standard objects.
Reema please get info about Sojects you will get the answer in it your query id correct just chect the child name once
This error is getting in your code because there is no relationship between product2 and orderitem. If you want to get the orderItem then check this query:-
List<pricebookentry> pbe=[SELECT id, Product2.Name, (select Id from OrderItems) FROM PricebookEntry];
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks and Regards
Suraj Tripathi.