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

PriceBook problem


     I have a problem regarding saving the quotelineitem. I have entered a product and also an unitprice hardcoded in the apex code and make UseStandardPrice=true. Then entered a pricebook name as well. The product is saved but the problem came in saving quotelineitem. I have assigned product2id and pricebook2id in the pricebookentry object. I have also assigned pricibookentryid and quoteid in quotelineitem object,but while saving an error is displaying. the error is like this

   System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, The pricebook entry is in a different pricebook than the one assigned to the Quote, or Quote has no pricebook assigned.: [PricebookEntryId]


                        Please help me out in this problem.



Ritesh AswaneyRitesh Aswaney

Set the Pricebook2Id on the Quote to the PriceBookId which you are using in your PriceBookEntries and referring in your QuoteLineItems.

The PriceBook needs to be set on the Quote (as also Opportunity) before using in Quote Line Items, I believe !


Do you have other products on the quote using another pricebook,  all products for a quote must reside in the same pricebook.


Thanks for replying. Yes I have set same pricebook2Id on the quote which I have set in pricebookentry object..But same error remains.


Two other thinks to try:


  • Im not fimiliar with the UseStandardPrice=true setting,  could this mean to use the standard pricebook? 
  • Is your org setup for multi-Currency?  be sure the pricebookentryId matchs both the currency and the pricebook2id on the quote.