i got error in my test class.

System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []

my test class.

public class TestSubscriberUpdateTrigger {

    public TestSubscriberUpdateTrigger(){

    public static testmethod void testSubscriberTrigger(){

        Account act = new Account();
        act.name = 'AllianceTek Inc';
        insert act;

        Date myDate = Date.newInstance(2014, 10, 01);
        Opportunity opt = new Opportunity();
        opt.name = 'Test Opps';
        opt.CloseDate = myDate;
        opt.StageName = 'New Opportunity';
        opt.Probability = 10;
        opt.Potential_DMP_Lives__c = 2;

        insert opt;

        Contact con = new Contact();
        con.LastName = 'Test AllianceTek';
        con.Is_Subscriber__c = false;
        insert con;              

        Product2 p2 = new Product2(Name='pro01',ProductCode='Fulfillment');
        insert p2;

        Pricebook2 pb = new pricebook2(name='price1');
        insert pb;

        PricebookEntry p = new PricebookEntry( Product2Id=p2.id, UnitPrice=0, PriceBook2Id=pb.id, UseStandardPrice=true);
        insert p; 

        sfcloud__Product_Bundle__c bn = new sfcloud__Product_Bundle__c();
        bn.Name = 'Testbn';
        bn.sfcloud__Description__c = 'dec';
        bn.sfcloud__Status__c = 'Draft';
        insert bn;

        Subscriber__c sub = new Subscriber__c();
        sub.Name = 'test01';
        sub.Subscriber_Contact__c = con.Id;
        sub.Subscriber_Account__c = act.Id;
        sub.Related_Opportunity__c = opt.Id;
        sub.Product_Bundle__c = bn.id;
        insert sub;                

        Subscriber__c sub2 = new Subscriber__c();
        sub2.Name = 'test02';
        sub2.Subscriber_Contact__c = con.Id;
        sub2.Subscriber_Account__c = act.Id;
        sub2.Related_Opportunity__c = opt.Id;
        insert sub2;       


i got error in insert p; statement. Help me please.

Thanks Vimal

  • You should have a standard price defined for the Product2 p2 before using it for a pricebook.
    – highfive
    Commented Oct 13, 2014 at 10:48
  • Thanks for reply. Lex give me that suggestion and now my test class run with 100% coverage. Commented Oct 13, 2014 at 14:21

2 Answers 2


You are assigning wrong id to that 'sfcloud__Price_Book__c'. In error '01uS0000006fgxDIAQ' it is the ID of Pricebook Entry.

Please ensure that you are assigning Price book id to sfcloud__Price_Book__c.

  • Thanks Raviteja. Its my mistake. Now my test class run perfectly with 100% coverage. Commented Oct 13, 2014 at 14:14

If you want to run tests involving price book entries, you have to add a price book entry for the standard price list first. You can do something like this:

Pricebook2 stdpb = [SELECT Id FROM Pricebook2 WHERE IsStandard = true];
PricebookEntry pbe = new PricebookEntry(Pricebook2Id = stdpb.Id, Product2Id = p2.Id, UnitPrice = 1);
insert pbe.

This will only work if you have seeAllData=true on your test.

  • Thanks for reply Lex. But Now i got this error. System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Price Book: id value of incorrect type: 01uS0000006fgxDIAQ: [sfcloud__Price_Book__c] Commented Oct 13, 2014 at 11:08
  • Did you create a custom object for price book as well? Or a custom object for price book entries? Commented Oct 13, 2014 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .