You need to sign in to do that
Don't have an account?
huskerwendy
@IsTest(SeeAllData=false) doesn't allow me to query products
I created a test class in API version 32 that is trying to query the Product2 to get the Product Name. It doesn't work unless I set SeeAllData=True. In my old classes, I can query the products table directly.
I thought that according to this we can set it to false again and still be able to get the products.
https://success.salesforce.com/ideaView?id=08730000000j9TpAAI
Here's my query.
Product2 prod = [select Id, Name, Included_Components__c, HasVersadoc__c from Product2 where Name =: productName];
Why doesn't that work unless I set "SeeAllDate=True"?
I thought that according to this we can set it to false again and still be able to get the products.
https://success.salesforce.com/ideaView?id=08730000000j9TpAAI
Here's my query.
Product2 prod = [select Id, Name, Included_Components__c, HasVersadoc__c from Product2 where Name =: productName];
Why doesn't that work unless I set "SeeAllDate=True"?
I also had this problem recently. You can access to standard pricebook id by Test.getStandardPricebookId(); Please refer to
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_test.htm#apex_System_Test_getStandardPricebookId
Hope you had already fixed your problem.
Cheers,
All Answers
Test data which creates in test class only exists during the context of Test class execution.
According to this idea, starting in the Summer 2014 release you should be able access the standard price book with that setting = False. Does that mean that you can access the price book but not the product? I'm confused.
https://success.salesforce.com/ideaView?id=08730000000j9TpAAI
I'm happy to announce that coming in the next release (Summer 2014), you will be able to access standard price book in your apex tests using @isTest(seeAllData=False) annotation.
I also had this problem recently. You can access to standard pricebook id by Test.getStandardPricebookId(); Please refer to
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_test.htm#apex_System_Test_getStandardPricebookId
Hope you had already fixed your problem.
Cheers,