You need to sign in to do that
Don't have an account?
emuelas
Create quotelineitem for test class
Hi ,
I have a test class where i need to be able to create a quotelineitem.
Can someone please help me with the code to create a quotelineitem for a test class?
Thanks!
Here's an example of creating an OpportunityLineItem in a test. You should be able to do the exact same thing but with a QuoteLineItem:
This is assumming you've already built an Opportunity called o1.
Hope this helps.
All Answers
Here's an example of creating an OpportunityLineItem in a test. You should be able to do the exact same thing but with a QuoteLineItem:
This is assumming you've already built an Opportunity called o1.
Hope this helps.
Hi kpeters,
Actually i used this and created a quote ,so the quote line item should automatically be created...but thats not happening,
I tried replacing opportunity product with quotelineitem values but that is erroring out
I was assumming you wanted to add a QLI in your test method after creating the quote. If you want the QLI to be automatically added to the quote based on the OLI in the opportunity, the quote has to be synced with the opportunity. AFAIK, there is no way to sync a quote to an opportunity in apex.
What error are you getting?
Hi ,
thank you so much!
Finally figured out the error....
the quote was not assigned any pricebook id...so changed that......
quote q=new quote(name='myquote',opportunityid=opp.id,pricebook2id=pb.id);
insert q;
quoteLineItem i = new quotelineitem();
i.quoteid = q.id;
i.pricebookentryid = pbe.id;
i.quantity = 1;
i.unitprice = 1;
Database.insert(i);