0

I am trying to Clone a Quote Record and its Quote Lines. The below code Clones the Quote Object but not the QuoteLines. I thought that there was a way to do the "DeepClone" by having the second parm of Clone be marked as True. Is it possible to use the clone function or must I have a SOQL query to fetch the child records?

@AuraEnabled(cacheable=false)   
public static void QuoteRevision(SBQQ__Quote__c Quote, id Quoteid){
 
 system.debug(logginglevel.debug, 'Start clsQuoteRevisionLWC = Quote            ' +  Quote);
 system.debug(logginglevel.debug, 'Start clsQuoteRevisionLWC = Quote            ' +  Quoteid);

Quote.SBQQ__Type__c = 'Revision';    

SBQQ__Quote__c clonedQuote = Quote.clone(false, true, false, true);

System.debug('clsQuoteRevisionLWC - Quote Number = ' + clonedQuote); 
insert clonedQuote;

}

1 Answer 1

1

DML operations only work on the object directly referenced in the sObject variable or list. To update parents or children, you must perform a separate DML on them. If you don't already have the child records in your variable, you'll need to do the appropriate queries. You'll also need to update the relationship fields manually.

You must log in to answer this question.

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