You need to sign in to do that
Don't have an account?

No standard price defined for this product error
Hi guys!
I am getting the below error on this test. class:
Error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []
Code:
@isTest private class ActiveAccountTest{ static testmethod void validateActiveAccount() { Account acc = new Account(); acc.name= 'test'; insert acc; Product2 newProd = new Product2 (Name = 'Test Product', ProductLine__c ='Test Product Line'); insert newProd; Opportunity oppObj = new Opportunity(Name = 'TestOpp',AccountID = acc.Id,Amount = 2000,CloseDate=Date.today(),StageName='A - Purchase / Close Won', MarketingGeneratedType__c = 'Sales'); insert oppObj; Pricebook2 customPB = new Pricebook2(Name='Test Product', isActive=true); insert customPB; PriceBookEntry pbEntry = new PriceBookEntry(UnitPrice = 100.00, PriceBook2Id = customPB.Id, Product2Id = newProd.Id, IsActive = true, UseStandardPrice = false); insert pbEntry ; OpportunityLineItem oppLine = new OpportunityLineItem(pricebookentryid=pbEntry.Id,TotalPrice=2000,Quantity = 1,OpportunityID = oppObj.Id); insert oppLine; Test.startTest(); Account acct4 = [Select custombox__c from Account limit 1]; Test.stopTest(); } }Can anyone help with this? Any hints would be appreciated!
The issue is because you haven't added your product to a standard priceboook. So, you need to create a PricebookEntry for the product with the standard pricebook.
Since its a test class you can get Id of the standard pb as, Once you get the Id you need to create a pricebook entry for the standard price, This should fix your issue.
Le