2

Can't wrap my head around this error. Any ideas?

@isTest
public class RemoveProductFamilyTriggerTest{

static testMethod void RemoveProductFamilyTriggerTestmethod()
{
    Date cd = date.parse('10/10/2018');
    Opportunity o = new Opportunity();
    o.Name='opp1';
    o.CloseDate=cd;
    o.StageName='Needs Analysis';
    o.Pricebook2Id=Test.getStandardPricebookId();
    insert o;
    Pricebook2 pb = new Pricebook2(
        Name='Testbook');
        insert pb;
    Product2 p1 = new Product2();
        p1.Name='product1';
        p1.Family='Card Present';
        insert p1;
    Quote q1 = new Quote();
        q1.Name='Quote 1';
        q1.OpportunityId=o.id;
        insert q1;
    PricebookEntry pbe = new PricebookEntry();
        pbe.Pricebook2Id=Test.getStandardPricebookId();
        pbe.Product2Id=p1.id;
        pbe.UnitPrice=3000;
        pbe.UseStandardPrice=false;
        insert pbe;
    OpportunityLineItem oli = new OpportunityLineItem();
        oli.Quantity=1;
        oli.UnitPrice=100;
        oli.OpportunityId=o.id;
        oli.PricebookEntryId=pbe.Id;
        insert oli;
    QuoteLineItem oli1 = new QuoteLineItem();
        //oli1.PricebookEntryId = pbe.Id;
        oli1.QuoteId = q1.Id;
        oli1.UnitPrice = 200;
        oli1.OpportunityLineItemId=oli.id;
    Test.startTest();
        insert oli1;
    Test.stopTest();
    //insert oli2;
    }
}
3

you have to make the pricebook entry Active In the part

    PricebookEntry pbe = new PricebookEntry();
    pbe.Pricebook2Id=Test.getStandardPricebookId();
    pbe.Product2Id=p1.id;
    pbe.UnitPrice=3000;
    pbe.UseStandardPrice=false;
    pbe.isActive=true;//Add this line
    insert pbe;
0
3

You need to set the IsActive flag to true on your Pricebook2, PricebookEntry, and Product2 records. The default value is to make these records inactive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.