function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BhatiaBhatia 

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
}

 

Alexander_EAlexander_E

Dear Bhatia,

 

I have almost the same issue and I am looking for an solution.

 

ListPrice and TotalPrice are emtpy in my tests too