I am trying to clone the records of a custom object. I know that I can use the deepClone() method of the List class to do this.
List<MyCustomObject__c> originalList = [Select Id, Name, Age From MyCustomObject__c Where Age = '20']; List<MyCustomObject__c> cloneList = originalList.deepClone();
My question here is I don't just want to clone the records with fields that I have in query (Name, Age) but I want the record to be cloned with all the fields that it has. For this do I need to put all the fields in my query or is there any other way to do this?