Friday, 9 March 2018

salesforce - Clone a record to create another record of same type

Run the below code in Excecute anonymous window of developer console.



QuoteLineItem qli=[SELECT Id,QuoteId, PricebookEntryId, Quantity, UnitPrice, Product2Id, Number_Eligible_Employees__c, Number_Expected_Enrolled__c, Single_Employer_Contribution__c FROM QuoteLineItem WHERE Id='0QL290000001ZN4'];
QuoteLineItem qli2=qli.clone(false,true,false,false);
insert qli2;





Note:
===

         List all the Required fields of the record in SELECT query.     

No comments:

Post a Comment