Error while saving Quote Lines:SBQQ.ValidationException: [": execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or 2 records: : []
Can anyone help me with the above error? I have tried using FOR UPDATE but it didn't work for me.
Do you guys have any alternative solutions?
Code Snippet
if(renewedSubscriptionids.size() > 0) {
for(Subscribed_Asset__c sa : [Select id, Subscription__c, Asset__c From Subscribed_Asset__c Where Subscription__c in : renewedSubscriptionids AND Create_Quote_Line_Serial_Number__c = true]) {
if(mapOfSubIdAndQuoteLine != null && mapOfSubIdAndQuoteLine.containsKey(sa.Subscription__c)){
Quote_Line_Serial_Number__c qlsn = new Quote_Line_Serial_Number__c(Account__c = quoteIdAccountIdMap.get(mapOfSubIdAndQuoteLine.get(sa.Subscription__c).SBQQ__Quote__c), Asset__c = sa.Asset__c, SB_Quote_Line__c = mapOfSubIdAndQuoteLine.get(sa.Subscription__c).Id);
qlsnToCreate.add(qlsn);
}
}}if(qlsnToCreate.size() > 0){
insert qlsnToCreate;}
Thanks Nirav