function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chris_centrachris_centra 

Standard Pricebook visibility - Summer 14 - still can't see it?

Hello.  This is an old test coverage issue.  Since api 24, you couldn't see the Standard Pricebook unless you used SeeAllData=true, so you couldn't write isolated test coverage.  I saw that this was patched in Summer 14 (https://success.salesforce.com/ideaView?id=08730000000j9TpAAI).  i'm trying to use it now, but it's not working.  i run this query: Pricebook2 pb = [SELECT Id FROM Pricebook2 WHERE IsStandard = true]; - but it says that no rows are returned.  (i updated the code to API 31 - although i'm not sure that was necessary.  And as far as i know, the sandbox is summer 14 - image is snorkel mask and "14.") 

Any idea what i am doing wrong?

thanks for your time.
chris
Best Answer chosen by chris_centra
Arunkumar RArunkumar R
Hi Chris,

Can you please create a new class with the below content and run the test class. If you get the Standard pricebookid then copy you problem class and delete it. Then create a new Class with the copied content.

@isTest
private class PriceBookTest
{

static void accessStandardPriceBook()
{

Id stdPriceBookRec = Test.getStandardPricebookId();
System.debug('---Std PriceBookId--'+stdPriceBookRec);

}

}

For more info, Please refer the below link http://salesforcekings.blogspot.in/2014/06/how-to-insert-opportunity-record-with.html

All Answers

Arunkumar RArunkumar R
Hi Chris,

Can you please create a new class with the below content and run the test class. If you get the Standard pricebookid then copy you problem class and delete it. Then create a new Class with the copied content.

@isTest
private class PriceBookTest
{

static void accessStandardPriceBook()
{

Id stdPriceBookRec = Test.getStandardPricebookId();
System.debug('---Std PriceBookId--'+stdPriceBookRec);

}

}

For more info, Please refer the below link http://salesforcekings.blogspot.in/2014/06/how-to-insert-opportunity-record-with.html
This was selected as the best answer
chris_centrachris_centra
That was it - thanks!!