I have created a webservice to create Opportunity, OpportunityLineItem and related Quote. When I do the same activity in configuration. QuoteLineItem gets created automatically. But when i do that same activity in code. The Opportunity is inserted, followed by OpportunityLineItem and related Quote**.But QuoteLineItem is not created.**

Am I missing something. Any help would be highly appreciated.

Following is the code used in test class.

 Date t = System.Today();
        Opportunity o1 = new Opportunity(Name = 'Opp1', StageName ='New', CloseDate = t);
        insert o1;
        Product2 p = new product2(name='unittest');
        p.Family = 'License';
        insert p;
        Id stdPbId = test.getstandardpricebookid();
        PricebookEntry pbe = new PricebookEntry(pricebook2id = stdPbid, product2id = p.id,unitprice=1.0,isActive=true);
        insert pbe;
        OpportunityLineItem oli = new OpportunityLineItem(PricebookEntryId=pbe.Id,OpportunityId=o1.Id,Quantity=10,TotalPrice=100);
        Quote q1 = new Quote(Name ='q1', OpportunityId = o1.Id,Pricebook2Id = stdPbid );
        insert q1;

        List<QuoteLineItem> qli = new List<QuoteLineItem>([Select id from QuoteLineItem where quoteId =: q1.Id]);
  • 1
    Without looking at the code, it is near impossible to tell what exactly is going wrong. Kindly paste your code here by editing your question. – Mahmood Nov 10 '17 at 12:12
  • Kindly paste only the minimal essence of your code that reproduces the problem using edit – cropredy Nov 10 '17 at 23:46

Your Answer

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

Browse other questions tagged or ask your own question.