I have try to clone Opportunity records and done till 3 fix field But I need for all fields.But without using clone() method.
Code -
public class Cloningwithout {
public static void insertclone(){
Opportunity opp = new Opportunity(Name='Opportunity2', CloseDate=date.parse('06/07/2012'),StageName='Prospecting');
insert opp;
ID Oppid =opp.ID;
clone1(Oppid);
}
public static void clone1(String IDs){
Opportunity sourceopp = [SELECT Id,Name,CloseDate,StageName from Opportunity Where Id=:IDs];
Opportunity targertopp = new Opportunity();
targertopp.Name = sourceopp.Name;
targertopp.CloseDate = sourceopp.CloseDate;
targertopp.StageName = sourceopp.StageName;
insert targertopp;
} }