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
maddy27maddy27 

Method does not exist or incorrect signature: void getStandardPricebookId() from the type Test

 //Create Quote Line Records
        
        Product2 p = new product2(name='unittest');
        p.Family = 'Media';
        p.IsActive = true;
        insert p;
        system.debug('++ Prod'+ p);
        
        // Id pricebookId = Test.getStandardPricebookId();
        
        Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true,Effective_From__c = date.today() , Effective_To__c= date.today()+60);
        insert pb;
        // First insert a price for the standard price book
        PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pb.id, Product2Id = p.Id,
            UnitPrice = 10000, IsActive = true,UseStandardPrice = false, Id = Test.getStandardPricebookId());

        insert standardPrice; 
          system.debug('standardPrice' + standardPrice);
        Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];
        PricebookEntry standardPBE = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = p.Id, UnitPrice = 1000, IsActive = true);
        insert standardPBE;
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = p.Id, UnitPrice = 1000, IsActive = true);
        insert pbe;
        system.debug('pbe' + pbe);
Best Answer chosen by maddy27
Raj VakatiRaj Vakati
try this 
 
PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pb.id, Product2Id = p.Id,
            UnitPrice = 10000, IsActive = true,UseStandardPrice = false, Id = System.Test.getStandardPricebookId());

Looks like you might have an apex class with the name "Test" .. that is causing issue

All Answers

Raj VakatiRaj Vakati
try this 
 
PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pb.id, Product2Id = p.Id,
            UnitPrice = 10000, IsActive = true,UseStandardPrice = false, Id = System.Test.getStandardPricebookId());

Looks like you might have an apex class with the name "Test" .. that is causing issue
This was selected as the best answer
Raj VakatiRaj Vakati
PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pb.id, Product2Id = p.Id,
            UnitPrice = 10000, IsActive = true,UseStandardPrice = false, Id = System.Test.getStandardPricebookId());

 
maddy27maddy27
thanks Raj V
Raj VakatiRaj Vakati
Is its working ?? If you are not using delete Test Apex Class .. other wise it giving same error 
maddy27maddy27
Hey Raj , it is now working fine. Thanks
maddy27maddy27
I have posted one more question , about forecast can you please help with that?? 
Raj VakatiRaj Vakati
Give me link pls and close this thread 
maddy27maddy27
Forecast Quota amount :  https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005nQiQAI