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: []