Reply
Trusted Contributor
ckellie
Posts: 411
0
Accepted Solution

List of Products not on the Pricebook

This is my first project where I need to make a list of products that are not in a pricebook. I have written the basic code below to render a list of products not included in a pricebook.

 

public class ProductsnotinFY13PB{
    
    id FY13PB = [select id from Pricebook2 where name = 'FY13 Global Pricebook'].id;
    
    List<Product2> inactivep = [select id from Product2 where (select id from pricebookentry where 
                                pricebook2id =: FY13PB).size()=0];
    
}

 and I am receiving the following error:

 

	Error: Compile Error: unexpected token: 'select' at line 5 column 63

 How do I correct this error?

 

Thanks

Trusted Contributor
crop1645
Posts: 360
0

Re: List of Products not on the Pricebook

I believe you need to use the IN and NOT IN operators here as in:

 

SELECT id, Name FROM Product2 where id NOT IN (select product2id from pricebookentry where pricebook2Id = :FY13PB)

 see: 

http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/index_Left.htm#StartTopic=Content/sforce...

Eric
Trusted Contributor
ckellie
Posts: 411
0

Re: List of Products not on the Pricebook

Thank you very much.