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
JeffStevensJeffStevens 

Error on adding Quote Line Item while quote is synced

I have a quote that is synced, but when I try to add a Quote Line Item - I get "An internal error occured during:" (details = java.lang.NullPointerException) .  I'm just running it under Execute-Anonymous.  If I stop the Sync - it runs just fine.  I do have triggers on my Quote/QLI and Opportunity/OLI - but I have all four of them InActive right now. Here is my code...

 

PriceBookEntry PBEtax = [SELECT Id FROM PriceBookEntry WHERE Product2.Name = 'Tax' LIMIT 1];
system.debug('PBEtax='+PBETax);

List<QuoteLineItem> QLIsToUpdate = new List<QuoteLineItem>();

QuoteLineItem QLI = new QuoteLineItem();
QLI.Quantity = 1;
QLI.UnitPrice = 5.00;
QLI.PricebookEntryId = PBETax.Id;
QLI.Total_Price__c = 5.00;
QLI.QuoteId = '0Q0Z00000008XLb';
QLIsToUpdate.add(QLI);


system.debug('QLIsToUpdate='+QLIsToUpdate);
upsert QLIsToUpdate;

 

Any thoughts?

 

Thanks,

Jeff

 

Best Answer chosen by Admin (Salesforce Developers) 
JeffStevensJeffStevens

Thanks for the reply.

 

I actually tracked it down to "bad Products".  I had a few products that I deleted from the products, and re-added them.  After I did that - I stopped getting my errors.

All Answers

sfdcfoxsfdcfox

Try checking your debug logs. Sounds like you have a null-pointer exception that occurs somewhere in your trigger on a line insert, possibly because some values haven't been synced yet?

JeffStevensJeffStevens

Thanks for the reply.

 

I actually tracked it down to "bad Products".  I had a few products that I deleted from the products, and re-added them.  After I did that - I stopped getting my errors.

This was selected as the best answer