Project Details
  (10.0 Reviews)
Super Clone - clone master and detail records in one click

Project Owner: jing hai li

Created: August 15 2011

Description's record clone function only clones the record itself without taking into the account of its "detail/child" records. The Super Clone provides both API (can be directly called from your own code) and visual force page UI access to clone the master and detail records in one go. An example of API access:

//clone an account record (id is a0190000001E3JJ) with all related detail records(contact,opportunity...) //note, detailed records to be cloned can be further declared. By default, it takes all child records.

Clone cc=new Clone();
string parentObjAPIName=cc.returnAPIObjectName('a0190000001E3JJ');
Map<string,string> objLabelobjAPI=cc.getAllChildObjNames(parentObjAPIName,'a0190000001E3JJ');
string clondedParentRecordID=cc.startsClone('a0190000001E3JJ', objLabelobjAPI.values());

That's it, totally 4 lines code.

To use it in a Visualforce page, all you need to do is to pass the master record id to the URL:
yoursalesforce master record id, e.g:

Development Team
The project owner is currently the only member of the development team.
Reviews - Showing 5 of 12
5 stars
(by Ramjee Kabra on Mon Jul 07 15:21:15 GMT 2014)
for the source code of the project click on "View Source". Its a customized code and not a salesforce provided class. You need to have the code in your org before you can use it.

5 stars
(by SRIRAM RAJESH on Mon Aug 26 06:42:22 GMT 2013)
It's very nice thing to clone all related records plz going on to post innovative projects :)

1 star
(by SFhasan SFshamsi on Thu Jun 27 11:00:00 GMT 2013)
Well this looks cool but there are some ambugities , I can not understand the Instance cc, when we do not have any Clone Object in salesforce, can you please elaborate this

4 stars
(by jotace on Fri Feb 01 12:23:13 GMT 2013)
Please, how can I use this code in a button???

5 stars
(by ankush rao on Mon Nov 19 06:57:10 GMT 2012)
There is no ''Clone '' object,so how can we create like this.. Clone cc=new Clone(); in my apex i get an Error,"Error: Compile Error: Invalid type: Clone"...please give the clear usage of Clone thank you

master  |  detail  |  clone  |  copy  |  record  |  apex