Skip to main content
added 2 characters in body
Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166

The Id column in your subquery is the Id of the PricebookEntry object. You want the reference field to Product2, Product2Id:

SELECT Id, ProductCode 
FROM Product2 
WHERE Id NOT IN (SELECT Product2Id 
                 FROM PricebookEntry 
                 WHERE Pricebook2Pricebook2Id = '01si0000003vpAlAAI') 

My first stop with this kind of issue is always the field reference for PricebookEntry (or whichever sObject is in question). It's a great resource for not just names but specific requirements and limitations around each standard field.

The Id column in your subquery is the Id of the PricebookEntry object. You want the reference field to Product2, Product2Id:

SELECT Id, ProductCode 
FROM Product2 
WHERE Id NOT IN (SELECT Product2Id 
                 FROM PricebookEntry 
                 WHERE Pricebook2 = '01si0000003vpAlAAI') 

The Id column in your subquery is the Id of the PricebookEntry object. You want the reference field to Product2, Product2Id:

SELECT Id, ProductCode 
FROM Product2 
WHERE Id NOT IN (SELECT Product2Id 
                 FROM PricebookEntry 
                 WHERE Pricebook2Id = '01si0000003vpAlAAI') 

My first stop with this kind of issue is always the field reference for PricebookEntry (or whichever sObject is in question). It's a great resource for not just names but specific requirements and limitations around each standard field.

Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166

The Id column in your subquery is the Id of the PricebookEntry object. You want the reference field to Product2, Product2Id:

SELECT Id, ProductCode 
FROM Product2 
WHERE Id NOT IN (SELECT Product2Id 
                 FROM PricebookEntry 
                 WHERE Pricebook2 = '01si0000003vpAlAAI')