2

I am currently on Summer 2020 CPQ. When creating test classes with more than one Quote line being inserted I am getting the below error? Any ideas as to why? looking through the debug logs the id appears to be from the opportunity. I wrote it both ways where creating a list and inserting individually.

 SBQQ__QuoteLine__c soQuoteLine0 = new SBQQ__QuoteLine__c
        (
         SBQQ__Quote__c = soQuote.Id,
         SBQQ__Product__c = ProductStandAlone.Id,
         Host__c = h.Id
        );
        
    Insert soQuoteLine0;

system.debug(logginglevel.debug, 'DEBUG: soQuoteLine    0           ' + soQuoteLine0.id);

        SBQQ__QuoteLine__c soQuoteLine1 = new SBQQ__QuoteLine__c
        (
           
         SBQQ__Quote__c = soQuote.Id,
         SBQQ__Product__c = ProductStandAlone.Id,
         Host__c = h.Id
        );
     
  //   try{
         
         Insert soQuoteLine1;



List<SBQQ__QuoteLine__c> lines = new List<SBQQ__QuoteLine__c>();
    lines.add(new SBQQ__QuoteLine__c(SBQQ__Quote__c = q.Id, Host__c = h.Id, SBQQ__Product__c = p.Id));
    lines.add(new SBQQ__QuoteLine__c(SBQQ__Quote__c = q.Id, Host__c = h.Id, SBQQ__Product__c = p2.Id));
    Insert lines;


System.DmlException: Insert failed. First exception on row 0; first error: 
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SBQQ.QuoteLineAfter: execution of AfterInsert

caused by: System.ListException: Duplicate id in list: 0064C00000CZdzUQAT 

Class.SBQQ.QuoteOpportunitySynchronizer.upsertAndDelOpportunityLineItems: line 243, column 1
Class.SBQQ.QuoteOpportunitySynchronizer.updateOpportunityProducts: line 35, column 1
Class.SBQQ.QuoteService.calculateAndSynch: line 214, column 1
Class.SBQQ.QuoteService.processLineTriggerAfter: line 1380, column 1
Trigger.SBQQ.QuoteLineAfter: line 23, column 1: []
1
  • did you ever have any luck solving this? I'm experiencing the same issue Commented May 14, 2022 at 3:14

2 Answers 2

2

I had the same issue with my test class. Solved it by adding the pricebook Id to the opportunity and quote. The line items I now create via the pricebookentry, not via the product.

Hope this helps someone in the future coming across this issue.

1
  • N.B. This is also true for OpportunityLineItems, QuoteItems, OrderItems, ServiceContractItems, etc.
    – cropredy
    Commented Nov 15, 2022 at 22:50
-1

The error seems to because you the product you are assigning to soQuoteLine1 is same as product for soQuoteLine0 and both are on the same quote.

1
  • Ya thats not it, you can have the same product on multiple lines... And the duplicate is opportunity
    – CodeMonger
    Commented Jul 3, 2021 at 4:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .