I am trying to deep clone the objects. I got the code for deep cloning from a blog http://christopheralunlewis.blogspot.com/2012/04/clone-plus-clone-salesforce-objects.html which is working perfectly for me. I have parent object as opportunity and child object as Line_item__c. After clicking clone button i want to be redirected to edit page. So i replaced
return new PageReference('/' + headClone.Id);
With:
return new PageReference('/' + headClone.Id + '/e');
But now it is redirecting me to home page on clicking save or cancel from edit page. Rather i would like to go detail page(which is a custom page) of newly cloned record on clicking save and old record detail page on clicking cancel.Please guide.