You need to sign in to do that
Don't have an account?
Issue with the listprice field in QuotelineItem in the Test class
I am running the Trigger in which i m trying to debug the "Trigger.new" in which i am not able to see the listprice field of QuoteLineItem. All other fields are displaying but not the listprice field. It is read only field. I am getting the value from PriceBookEntry's unitprice field into the listprice field of QuoteLineItem. When I am checking the QLI(QuoteLineItem)
has been inserted. I am able get the value in listprice field but it is not displaying in the Trigger.new. By this i am not able to do my Test Coverage 100%. It is just coming 47%.
Any help will be appreciated in this regard.
Trigger
---------------------
trigger SampleTestTrigger on QuoteLineItem(before insert, before update)
{
for(QuoteLineItem li: Trigger.new){
if(li.listprice!=null)
{
If(li.unitprice!=null){
if(li.discount==null)
{
-- some code here--
li.unitprice=li.listprice;
}
}
}
}
Test Class
------------
PricebookEntry pbe=new PricebookEntry();
pbe.Pricebook2Id=pb.id;
pbe.Product2Id=p.id;
pbe.IsActive=true;
pbe.UnitPrice=10;
insert pbe;
QuoteLineItem qli = new QuoteLineItem();
qli.quoteId=q.id;
qli.pricebookentryid=pbe.id;
qli.quantity=1;
qli.unitprice=5;
qli.discount=0.02;
insert qli;
qli.discount=null;
Test.startTest();
update qli;
Test.stopTest();
// checking the QLI has been inserted
for(QuoteLineItem y :[select discount,unitprice,listprice from quotelineItem where createdDate=Today and unitprice=5])
{
// here value of listprice coming
}
Dear Bhatia,
I have almost the same issue and I am looking for an solution.
ListPrice and TotalPrice are emtpy in my tests too