我尝试对SalesForce Db执行左外连接,以从Product2表获取Id和ProductCode字段,并从关联(如果存在)PriceBookEntry获取一些字段。我也有PriceBook2,id ='01sd00000008iWpAAI'。以下是示例查询:
SELECT Id, ProductCode,
(SELECT Id, PriceBook2Id, PriceBookEntry__r.Product2Id FROM PriceBookEntry__r
WHERE PriceBook2Id='01sd00000008iWpAAI')
FROM Product2 WHERE ProductCode IN
('151','250','256','270','289')
返回给我的错误是:
INVALID_TYPE: PriceBookEntry__r.Product2Id FROM PriceBookEntry
WHERE PriceBook2Id='01sd00000008iWpAAI')
^ ERROR at Row:1:Column:89
Didn't understand relationship 'PriceBookEntry__r' 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..
我为此查询尝试了几种变体,但没有成功。我在Product2表中有这些ProductCodes的行。
我想念那里?
答案 0 :(得分:1)
我找到了解决方案: 关键是表PriceBookEntry。 它应该是复数(PriceBookEntries)。所以查询应该是:
SELECT Id, ProductCode,
(SELECT Id, PriceBook2Id, Product2Id FROM PriceBookEntries
WHERE PriceBook2Id='01sd00000008iWpAAI')
FROM Product2 WHERE ProductCode IN
('151','250','256','270','289')