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
SFDC_DevloperSFDC_Devloper 

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]

Hi All,

  I a facing below issue while inserting new quote line iteam, please help to fix this.

 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]
 
lineItemList=[select Name,ID,product2.Name,PriceBookEntryID,priceBookEntry.product2.productcode,Discount,product2ID,OpportunityID,ProductCode,ListPrice,UnitPrice,Quantity,TotalPrice  from OpportunityLineItem where OpportunityID=:recordID];
     for(OpportunityLineItem  lineItem:lineItemList)
     {
//Quote.iD is recoord id
QuoteList.add(new QuoteLineItem(QuoteID=Quote.ID,
PriceBookEntryID=lineItem.PriceBookEntryID,
Product2ID=lineItem.product2ID,
UnitPrice=lineItem.ListPrice,
Quantity=lineItem.Quantity));

} 

insert QuoteList;

Thanks.